按照如下VB代码,怎么写JAVA连接数据源的JDBC代码,谢谢
按照如下代码,我想用java连接数据库以便获取数据,因为下面代码好像是从数据源里获取数据的,所以我想java要用桥接方式获取数据,但写了java代码,但是没成功
VB代码
Set objConnection = CreateObject("ADODB.CONNECTION")
strConnectionString = "DSN=AR System ODBC Data Source;ARServer=globalar.jci.com;UID=ayuang;PWD=Jame12$;ARAuthentication=;ARUseUnderscores=1;SERVER=NotTheServer"
objConnection.Open strConnectionString
If (objConnection.State = 1) Then
MsgBox "数据库连接成功!"
End If
If (objConnection.State = 0) Then
MsgBox "连接数据库失败!"
End If
i = 0
str_Array_QueryResult = Array() '重新初始化数组为一个空数组
Set rs = CreateObject("ADODB.RECORDSET") '4 - 建立RECORDSET对象实例
Set objCommand = CreateObject("ADODB.COMMAND") '5 - 建立COMMAND对象实例
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "SELECT "&chr(34)&"HPD:HelpDesk"&chr(34)&"."&chr(34)&"Case ID+"&chr(34)&" from "&chr(34)&"HPD:HelpDesk"&chr(34)&" "&chr(34)&"HPD:HelpDesk"&chr(34)&" WHERE ("&chr(34)&"HPD:HelpDesk"&chr(34)&"."&chr(34)&"Assigned To Group+"&chr(34)&" Like "&chr(39)&"%apac.gen.as%"&chr(39)&") OR ("&chr(34)&"HPD:HelpDesk"&chr(34)&"."&chr(34)&"Entry Group"&chr(34)&" Like "&chr(39)&"%apac.gen.as%"&chr(39)&") ORDER BY "&chr(34)&"HPD:HelpDesk"&chr(34)&"."&chr(34)&"Case ID+"&chr(34)&""
rs.CursorLocation = 3
rs.Open objCommand
JAVA代码
String dbur1 = "jdbc:odbc:AR System ODBC Data Source";
conn = DriverManager.getConnection(dbur1,"ayuang","Jame12$");
Statement stmt = conn.createStatement();
rs = stmt.executeQuery("select * from HPD:HelpDesk");
请问上面JAVA代码哪里写错了,请指教,还有就是按照VB代码,数据库名是什么?
------解决方案--------------------
Class.forName("驱动名");String dbur1 = "jdbc:odbc:AR System ODBC Data Source";
conn = DriverManager.g