Nu kan jeg connecte til MS-sql-server via JdbcOdbcDriver. Pludselig virkede
det ved brug af Forte-compileren i stedet for bare JRE. Hvis jeg bruger de
to udkommenterede linjer herunder så virker det ikke, men ved brug af de
andre 2 virker det altså fint. Mange tak for jeres hjælp Dennis, Lars,
Mikkel, Thorbjørn, Morten m.v.
Venlig Hilsen Michael
//------------------------------------
import java.util.Properties;
import java.sql.*;
class DBExample{
public static void main( String[] args ){
Driver driver = null;
Connection connection = null;
String userName = "me";
String password = "secret";
String server = "jdbc
bc:kk";
Properties properties = new Properties();
properties.put( "user", userName );
properties.put( "password", password );
try{
driver = new sun.jdbc.odbc.JdbcOdbcDriver();
connection = driver.connect( server, properties );
// Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Connection con = DriverManager.getConnection(server, userName,
password);
PreparedStatement pstmt = connection.prepareStatement( "SELECT * FROM
tabel1" );
ResultSet rs = pstmt.executeQuery();
while( rs.next() ){
System.out.println( "Navn: " + rs.getString(1) + " " +
rs.getString(2) );
}
pstmt.close();
}catch(Exception e ){
e.printStackTrace();
}
}
}
//------------------------------------