Hi, my commpany going to java, currently I am a VB programer, so I am trying to learn Java. We do a lot with Access adn SQL Server databases, sofar I found that the code below works great for Ms Access, but how would I do it if it where a table in SQL Server I wnted to connect to.
Can someone tell me how I would do this, or tell me where I can go get this information; because I have searched the net and cannot find it.
Thank You
import java.sql.*;
public class Test2
{
public static void main(String[] args)
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String filename = "C:/Orders.mdb";
String database = "jdbcdbcriver={Microsoft Access Driver (*.mdb)};DBQ="; database+= filename.trim() + ";DriverID=22;READONLY=true}";
Connection con = DriverManager.getConnection( database ,"","");
Statement s = con.createStatement();
s.execute("Update TEST12345 Set column_name = 4");
s.execute("select column_name from TEST12345");
ResultSet rs = s.getResultSet();
if (rs != null)
while ( rs.next() )
{
System.out.println("Data from column_name: " + rs.getString(1) );
}
s.close();
con.close();
}
catch (Exception err) {
System.out.println("ERROR: " + err);
}
}
}
Can someone tell me how I would do this, or tell me where I can go get this information; because I have searched the net and cannot find it.
Thank You
import java.sql.*;
public class Test2
{
public static void main(String[] args)
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String filename = "C:/Orders.mdb";
String database = "jdbcdbcriver={Microsoft Access Driver (*.mdb)};DBQ="; database+= filename.trim() + ";DriverID=22;READONLY=true}";
Connection con = DriverManager.getConnection( database ,"","");
Statement s = con.createStatement();
s.execute("Update TEST12345 Set column_name = 4");
s.execute("select column_name from TEST12345");
ResultSet rs = s.getResultSet();
if (rs != null)
while ( rs.next() )
{
System.out.println("Data from column_name: " + rs.getString(1) );
}
s.close();
con.close();
}
catch (Exception err) {
System.out.println("ERROR: " + err);
}
}
}