| |

VerySource

 Forgot password?
 Register
Search
Author: cm200red

Java query SQLServer encountered a problem: the object name is invalid.

[Copy link]

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-1 14:15:01
| Show all posts
Are there keywords in the table?
Ha ha
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-2 18:15:01
| Show all posts
java.sql.SQLException: [Microsoft][SQLServer Driver for JDBC][SQLServer] object name ‘xxx’ is invalid


root cause:

The user who accesses the database has login permission, but no permission to operate the table

Solution:

1. In the [Enterprise Console] window-[Tree] sub-window-[Security] sub-tree-[Login] item, set the default database of the login user you use to the database you use.

2. Add a login user in the [Enterprise Console] window-[Tree] sub-window-[Security] sub-tree-[Login] item (select SQL Server authentication, server role and database to be accessed) , Some new users will be able to access the database you selected in the future.

I also encountered the problem of the original poster, and I felt like crying without tears, and finally solved it with this method! ! ! ! ! ! ! ! ! !
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-2 18:30:01
| Show all posts
Explain that there is no such table
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-3 18:30:01
| Show all posts
The default database is wrong
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-5 08:00:01
| Show all posts
That's right, it is to modify the default database of the logged in user! But why is this? The name of the database is clearly indicated in the url! why? ? ?
[color=#FF0000]Solve...[/color]
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-5 10:30:01
| Show all posts
I just encountered this problem, because the user of the current database does not have permission. Select the table you want to operate, right-click and select properties, then click permissions, and then check the permissions that your user needs.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-5 10:45:01
| Show all posts
The landlord must have written the wrong name of the database used to connect java to sql server.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-5 11:00:01
| Show all posts
Generic error.

Write this statement in SQL
use database name

Run OK
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-6 02:30:01
| Show all posts
Just follow the55924321approach! ! ! Thanks a lot! ! ! ! ! ! ! ! !
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-6 21:15:01
| Show all posts
When a non-sysadmin fixed server role member (non-DBA user) creates a new database object in the query analyzer or program (asp, vb, etc.), the owner of the database object is the current logged-in user. If the program is changed to run as a DBA or other identity the next time, it will prompt that the database object cannot be found.

For example: If the user Andrew is not a member of the fixed server role sysadmin, but only a member of the fixed database role db_owner, and creates the table T1, then T1 belongs to Andrew and is limited to Andrew.T1. Other users need to add the owner in front of the table when using SQL statements in the query analyzer or program to access the table:

                  select * from Andrew.T1

               But not directly

                  select * from T1

                   Otherwise, you will be prompted that the table object cannot be found.
In the [Enterprise Console] window-[Tree] sub-window-[Security] sub-tree-[Login] item, set the default database of the login user you use to the database you use.
Server role: system administrator cannot be checked, otherwise the owner must be added when querying the table. (Select * from Andrew.T1)
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list