ms sql server 2005 sa account can not access the database i created while the system databse is ok

StackOverflow https://stackoverflow.com/questions/14135046

  •  12-01-2022
  •  | 
  •  

Question

Just like the title said. I try to write a tutorial to show how to communicate with the ms sql server.

And I can communicate with the system database such like master and model. But while I create a database manually, I can't access the database. All I got is: can't open the request database.

       String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
       String dbURL = "jdbc:sqlserver://127.0.0.1:1433; DatabaseName=ddf"; //ddf is what I created.
       String userName = "sa";
       String userPwd = "123456";
       Class.forName(driverName);
   dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
   System.out.println("Connection Successful!"); 
   Statement stmt = dbConn.createStatement();
   String sql = "select * from ddf..ff";
   ResultSet rs = stmt.executeQuery(sql);
   while(rs.next()){
       System.out.println(rs.getRow());
   }
   rs.close();
   stmt.close();
   dbConn.close();

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top