Hi,
I am learning java for my job, and they are starting to show me JDBC and we use SQL Server for a database. So I am trying to get a simple progam to work.ich retuns the customers addres form the database; but it is geting stuck on the line DriverManager.getConnection and the line stmt.ExecuteQuery(sqlCmdString);
can someone tell me what I am doing wrong.
Thank you
import java.sql.*;
class Sqlmain {
public static void main(String args[])
{
Class.forName ("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url = "jdbc:microsoft:sqlserver://:1433";
Connection con = DriverManager.getConnection(url, "Customers");
con.setCatalog("northWind");
Statement stmt = con.createStatement();
String sqlCmdString = "select * from Customers";
ResultSet rs = stmt.ExecuteQuery(sqlCmdString);
while (rs.next())
{
rs.getString(("address").trim());
}
}
}
I am learning java for my job, and they are starting to show me JDBC and we use SQL Server for a database. So I am trying to get a simple progam to work.ich retuns the customers addres form the database; but it is geting stuck on the line DriverManager.getConnection and the line stmt.ExecuteQuery(sqlCmdString);
can someone tell me what I am doing wrong.
Thank you
import java.sql.*;
class Sqlmain {
public static void main(String args[])
{
Class.forName ("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url = "jdbc:microsoft:sqlserver://:1433";
Connection con = DriverManager.getConnection(url, "Customers");
con.setCatalog("northWind");
Statement stmt = con.createStatement();
String sqlCmdString = "select * from Customers";
ResultSet rs = stmt.ExecuteQuery(sqlCmdString);
while (rs.next())
{
rs.getString(("address").trim());
}
}
}