I have been looking for the solution from 2 days and tried everything but still i am not able to resolve the issue i am facing. Issue : Invalid object name 'Info'
package test;
import java.sql.*;
public class DataConn {
public static void main(String arg[]){
try{
//Load JDBC driver
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
//Establish connection
String url = "jdbc:sqlserver://localhost\\SQL2014:1433;databaseName=Test;integratedSecurity=true";
Connection con = DriverManager.getConnection(url);
System.out.println("Connection success");
//fetch data from Info
Statement st = con.createStatement();
String sql = "SELECT * FROM Info";
ResultSet rs = st.executeQuery(sql);
//extract
while(rs.next()){
String Name = rs.getString("Name");
String Class = rs.getString("Class");
int age = rs.getInt("Age");
System.out.println("Name: "+Name +"\t"+"Class: "+Class+"\t"+"Age: "+age);
}
rs.close();
con.close();
}
catch(Exception e){
System.err.println("Got an Exception!");
System.out.println(e.getMessage());
}
}
}
Output:
Connection success
Invalid object name 'Info'.
Got an Exception!
I am using Eclipse and Sql server 2014, I tried most of the things like: 1. [databasename].[dbo].[Info] 2. Test.dbo.Info
But I end up getting the same error: Invalid Object Name
Here is the Screenshot of SqlServer 2014: