JAVA链接DB2数据库的例子
文章作者 100test 发表时间 2007:03:14 16:37:20
来源 100Test.Com百考试题网
package com.wisdom.
import java.lang.StringBuffer.
import java.sql.Connection.
import java.sql.PreparedStatement.
import java.sql.DriverManager.
import java.sql.*.
import com.wisdom.base.DateUtil.
public class Test
{
public Test()
{
}
public static void main(String[] args)
{
Test test = new Test().
Connection conn = null.
try
{
Class.forName("com.ibm.db2.jcc.DB2Driver").
conn = DriverManager.getConnection(
"jdbc:db2://192.168.0.93:50000/CPICSMS", "administrator",
"rose").//来源:www.examda.com
test.save(conn).
}
catch (SQLException ex)
{
ex.printStackTrace().
}
catch (ClassNotFoundException ex)
{
}
finally
{
try
{
if (conn != null)
{
conn.close().
}
}
catch (SQLException ex1)
{
}
}
}
private void save(Connection conn)
{
if (conn == null)
return.
PreparedStatement pstmt = null.
StringBuffer sb = new StringBuffer("").
sb.append("insert into SM_PrioritySend_SM_List(ServiceID, SMContent, SendTarget, Priority, RCompleteTimeBegin,")