JDBC-Basics
Hi! I'm new to JDBC, but I've been useing ODBC for quite some time. Can anyone tell me what the syntax is?
A typpical ODBC to SQL Server connection string:
"DRIVER=SQL Server;SERVER=serverName;DATABASE=dataSourceName;UID=userId;PWD=password"
What would be the match in JDBC?
Thanks in advance!
Torbjorn Titlestad
tortitle@online.no
[383 byte] By [
Titlestad] at [2007-9-26 1:21:21]

This one connects to an AS400.
public void makeConnection()
{
try
{
DriverManager.registerDriver(new AS400JDBCDriver());
DriverManager.setLoginTimeout(10);
connection = DriverManager.getConnection ("jdbc:as400://" + system, user, pwdStr);
dmd = connection.getMetaData ();
}
catch (Exception e)
{
System.out.println("User " + user + " did not connect to " + system);
System.out.println ("ERROR: " + e.getMessage());
System.exit (0);
}
}
Klint
saen at 2007-6-29 0:56:55 >

this one is for jdbc:odbc
Connection connection;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection = DriverManager.getConnection("jdbc:odbc:<DSN>", "<username>", "<userpass>");
} catch (SQLException) {}
I suggest you also go through jdbc tutorial (beginner) at java.sun site.