'sybase'에 해당되는 글 1건
- 2008.07.14 sybase 간단한 접속 테스트
2008. 7. 14. 18:23
sybase 간단한 접속 테스트
2008. 7. 14. 18:23 in IT일반/Java
import java.sql.*;
public class SybaseDBConn {
public static void main( String[ ] args ) {
try {
Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );
} catch( ClassNotFoundException ex ) {
System.err.printf( "error : ", ex.toString() );
System.exit( 0 );
}
Connection conn = null;
String url = "jdbc:sybase:Tds:127.0.0.1:2638/SPSDB";
String id = "DBA";
String pass = "sql";
Statement stmt = null;
ResultSet rs = null;
String query = "SELECT * FROM sps_systemprefstable";
try {
conn = DriverManager.getConnection( url, id, pass );
stmt = conn.createStatement();
rs = stmt.executeQuery(query);
while( rs.next() ) {
System.out.println( rs.getInt(1) + " : " + rs.getString(2) );
}
rs.close( );
stmt.close( );
conn.close( );
} catch( SQLException ex ) {
System.err.println( "SQL Exception : " + ex.toString() );
System.exit( 0 );
}
}
}
public class SybaseDBConn {
public static void main( String[ ] args ) {
try {
Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );
} catch( ClassNotFoundException ex ) {
System.err.printf( "error : ", ex.toString() );
System.exit( 0 );
}
Connection conn = null;
String url = "jdbc:sybase:Tds:127.0.0.1:2638/SPSDB";
String id = "DBA";
String pass = "sql";
Statement stmt = null;
ResultSet rs = null;
String query = "SELECT * FROM sps_systemprefstable";
try {
conn = DriverManager.getConnection( url, id, pass );
stmt = conn.createStatement();
rs = stmt.executeQuery(query);
while( rs.next() ) {
System.out.println( rs.getInt(1) + " : " + rs.getString(2) );
}
rs.close( );
stmt.close( );
conn.close( );
} catch( SQLException ex ) {
System.err.println( "SQL Exception : " + ex.toString() );
System.exit( 0 );
}
}
}