Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Database/JDBC/SQL/JDO/Hibernate » MS SQL  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 请教用ODBC连接SQL的问题!!!!!
lyl5120



发贴: 0
积分: 0
于 2004-05-09 10:57 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
代码是:
import java.sql.*;

public class NorthwindSQLServerODBCDemo {
public static void main(String[] args) throws Exception {
String url = "jdbc:odbc:lyl";//lyl为SQL服务器名,在本机上的SQL服务器
Connection conn;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("JDBC-ODBC的驱动程序注册成功");
}catch(Exception e){
System.out.println("找不到JDBC-ODBC的驱动程序");
}
try{
conn = DriverManager.getConnection(url, "sa", "000000");
System.out.println("数据库联接成功");
}catch(Exception e){
System.out.println("url定义错误,找不到相关的数据源");
e.printStackTrace();
}
}
}

错误见图片,



作者 Re:请教用ODBC连接SQL的问题!!!!! [Re:lyl5120]
Lomone



发贴: 0
积分: 0
于 2004-05-16 22:25 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
是不是用sql 2000的


作者 Re:请教用ODBC连接SQL的问题!!!!! [Re:lyl5120]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2004-05-16 23:43 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Are you sure you have set up the ODBC datasource lyl (为SQL服务器名,在本机上的SQL服务器) correctly?

i.e. Control Panel-->Administrative Tools-->Data Sources (ODBC)-->System DSN ..... and test the Datasource


why edited on 2004-05-17 00:06

作者 Re:请教用ODBC连接SQL的问题!!!!! [Re:lyl5120]
lyl5120



发贴: 0
积分: 0
于 2004-05-19 12:12 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
i'm sure that is correct.software is ms sql2000.
system DSN---latter,the test is success.
there is a problem:the error is same in spite of my sql server is started or not.



作者 Re:请教用ODBC连接SQL的问题!!!!! [Re:lyl5120]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2004-05-19 12:30 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
> String url = "jdbc:odbc:lyl";//lyl为SQL服务器名,在本机上的SQL服务器
???
I believe it should be jdbc:odbc:[DSNname]



作者 Re:请教用ODBC连接SQL的问题!!!!! [Re:lyl5120]
lyl5120



发贴: 0
积分: 0
于 2004-05-24 19:27 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
首先感谢总版主的指点,我将
String url = "jdbc:odbc:lyl";//lyl为SQL服务器名,在本机上的SQL服务器
改为
String url = "jdbc:odbc:192.168.0.100";//本IP为本机IP,
但还是有错,请提示一下整个包括SQL设置的全过程,谢谢~



作者 Re:请教用ODBC连接SQL的问题!!!!! [Re:lyl5120]
vince96



发贴: 0
积分: 0
于 2004-05-25 10:53 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
请总斑竹把ODBC的数据源设置成连接远程数据库的全过程说一下吧,我也很想知道~~~~



flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923