[java] SQLServer jdbc接続
http://www02.so-net.ne.jp/~kikuta/jdbcnote/jdbcnote.html
http://support.microsoft.com/?scid=kb;ja;313100
http://www.ki.rim.or.jp/~kuro/Java/JDBC/JDBC-01.html
http://www.ki.rim.or.jp/~kuro/Java/JDBC/JDBC-02.html
— my source
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
public class jdbctest
{
public static void main(String[] args){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String strConn = "jdbc:odbc:Ods01";
java.sql.Connection Conn =
DriverManager.getConnection(strConn,"sa","sa");
java.sql.Statement st=Conn.createStatement();
java.sql.ResultSet rs = st.executeQuery("SELECT * from sysobjects;");
while(rs.next())
{
System.out.println(rs.getString(2));
}
rs.close();
st.close();
Conn.close();
}
catch(java.sql.SQLException ex)
{
System.out.println("SQL Exception :" + ex);
ex.printStackTrace();
}
catch(Exception e){
System.out.println("Error:" + e);
e.printStackTrace();
}
}
}
コメントはまだありません。