jdbc连接sql serverde

songnuan 2000-08-17 03:12:00
...全文
192 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
borz 2000-08-19
  • 打赏
  • 举报
回复
JDK的文档里不是有JDBC GETSTART吗?
那里有一个完整的访问ODBC数据源的代码
spczhou 2000-08-19
  • 打赏
  • 举报
回复
他们答的是对的
Jackzhu 2000-08-18
  • 打赏
  • 举报
回复
1、在odbc数据源设置数据源ttt连接到sqlserver
2、使用jdbc-odbc桥连接
例子:
// sql server 7.0
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
try
{
conn = DriverManager.getConnection("jdbc:odbc:ttt", "sa", "");
}
catch(SQLException e)
{
System.out.println(e.getMessage());
System.exit(1);
}
}
catch (Exception e)
{
System.out.println(e);
System.exit(1);
}
zgq 2000-08-18
  • 打赏
  • 举报
回复
try
{
Class.forName("com.internetcds.jdbc.tds.Driver");
try
{

String url = "jdbc:freetds:sqlserver://127.0.0.1:1433/pub";
String user = "sa";
String password = "";
conn = DriverManager.getConnection(url,sa,password);
}
catch(SQLException e)
{
System.out.println(e.getMessage());
System.exit(1);
}
}
catch (Exception e)
{
System.out.println(e);
System.exit(1);
}

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧