• 全部
  • Java SE
  • Java EE
  • J2ME
  • IDE工具
  • 求助
  • 内推招聘
  • 问答

带用户和密码的JDBC连接字符串(SYBASE)怎么写?

s_phoenix 2004-11-08 03:16:08
jdbc:sybase:Tds:133.40.5.7:6000/workdb?charset=eucgb&jconnect_version=4;
如果要增加登录的用户和密码,怎么写呢?
多谢!
...全文
238 点赞 收藏 10
写回复
10 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
drugon 2004-12-17
到网上去找吧,有一次我也是用一句,试了好长时间,不过连的是SQLServer,可以给你作参考吧!jdbc:microsoft:sqlserver://210.22.25.62:1433;DatabaseName=mobile;user=sa;password=123456
回复
zhangzhihua 2004-12-16
你用的什么jDBC驱动啊//
回复
frhwxx 2004-11-25
jsp连接Sybase数据库
  testmysql.jsp如下:
  <%@ page contentType="text/html;charset=gb2312"%>
  <%@ page import="java.sql.*"%>
  <html>
  <body>
  <%Class.forName("com.sybase.jdbc.SybDriver").newInstance();
  String url =" jdbc:sybase:Tds:localhost:5007/tsdata";
  //tsdata为你的数据库名
  Properties sysProps = System.getProperties();
  SysProps.put("user","userid");
  SysProps.put("password","user_password");
  Connection conn= DriverManager.getConnection(url, SysProps);
  Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
  String sql="select * from test";
  ResultSet rs=stmt.executeQuery(sql);
  while(rs.next()) {%>
  您的第一个字段内容为:<%=rs.getString(1)%>
  您的第二个字段内容为:<%=rs.getString(2)%>
  <%}%>
  <%out.print("数据库操作成功,恭喜你");%>
  <%rs.close();
  stmt.close();
  conn.close();
  %>
  </body>
  </html>
回复
s_phoenix 2004-11-25
我想做session持久化,在tomcat重启的时候,把当前session存放到数据库中,重启后,自动从数据库中恢复.
其中必须用到一句话的数据库连接。
回复
xueqs 2004-11-25
为什么非要写在一句里
回复
xueqs 2004-11-25
gz
回复
s_phoenix 2004-11-25
看清我的问题再转贴代码,好吗?
回复
s_phoenix 2004-11-08
采用j2nix的方法:
2004-11-8 16:00:31 org.apache.commons.digester.Digester fatalError
严重: Parse Fatal Error at line 11 column 85: The reference to entity "jconnect_version" must end with the ';' delimiter.
org.xml.sax.SAXParseException: The reference to entity "jconnect_version" must end with the ';' delimiter.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanAttribute(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1567)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:488)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:863)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:482)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:968)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:480)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)
2004-11-8 16:00:31 org.apache.catalina.startup.HostConfig deployDescriptors
严重: Error deploying configuration descriptor tsefweb.xml
java.io.IOException: org.xml.sax.SAXParseException: The reference to entity "jconnect_version" must end with the ';' delimiter.
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:494)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:863)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:482)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:968)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:480)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)

怎么办?难道SYBASE没有办法在一句连接字符串里写全?
回复
j2nix 2004-11-08
参考:
http://6vv6.com/down/listinfo.asp?id=536
http://6vv6.com/down/listinfo.asp?id=537
回复
j2nix 2004-11-08
jdbc:sybase:Tds:133.40.5.7:6000/workdb?charset=eucgb&jconnect_version=4&user=xxx&password=xxx;
回复
相关推荐
发帖
Java
创建于2007-09-28

4.7w+

社区成员

Java相关技术讨论
申请成为版主
帖子事件
创建了帖子
2004-11-08 03:16
社区公告
暂无公告