2

I have connect MSSQL server through java using following Code

Connection conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DATABASENAME=;instanceName=MSSQLSERVER", "DB_USER_NAME", "DB_PASSWORD");

After that I am able to connect database and execute sql script without giving any object name. for example

SELECT * FROM TEST_TABLE

Now, I have some tables which are got created under dbo and I want to access them using same connect. How Can I go with this? I have try with

SELECT * FROM dbo.TEST_TABLE1

but it says that this table is not there in database.

5
  • add your database name in connection string Commented Feb 23, 2015 at 8:36
  • jdbc:sqlserver://localhost;databaseName=AdventureWorks;integratedSecurity=true; Commented Feb 23, 2015 at 8:42
  • I had tried with that too. But the result is same. Commented Feb 23, 2015 at 9:46
  • Immediately after establishing your JDBC connection do SELECT DB_NAME() AS currentdb and verify that you are actually using the database you think you are using. If so, then log into SQL Server Management Studio (SSMS) with the same credentials you are using in your Java code and try to access the dbo. tables that way. Commented Feb 23, 2015 at 12:13
  • @Navnath Please provide more details of your problem so that we can help you in a more accurate way Commented Feb 23, 2015 at 14:33

1 Answer 1

0

Make your DB user to the DB owner.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.