谁能给我整个Sybase的数据库连接类啊
如题:我是一个才接触Sybase数据库 哪位大侠指导下啊
最后有点注释
[解决办法]
你用的是什么语言?
[解决办法]
下载一个sybase 的 ado.net 的库就行了。你到sybase 的官网找一下试试。
[解决办法]
直接下载一个SYBASE的驱动就OK了,连接字串
Provider=Sybase.ASEOLEDBProvider.2;
Initial Catalog=数据库名;
User ID=用户名;Data Source=数据源;
Extended Properties="";
Server Name=ip地址;
Network Protocol=Winsock;
Server Port Address=5000;
[解决办法]
public class DbConnection { private static String driverName = "com.sybase.jdbc3.jdbc.SybDriver"; //private static String url = "jdbc:sybase:Tds:192.1.168.200:5000/project"; private static String url = "jdbc:sybase:Tds:127.0.0.1:5000/project"; //private static String url = "jdbc:sybase:Tds:10.232.80.239:5000/TestPro"; private static String user = "sa"; private static String password = ""; private static String jdbcJNDI = "java:comp/env/jdbc/pro"; public DbConnection(){ } public static Connection getConnection1() throws SQLException{ //第一种jndi连接方法 try { Context ctx = new InitialContext(); DataSource ds = (DataSource) ctx.lookup(jdbcJNDI); return ds.getConnection(); } catch (Exception ex) { ex.printStackTrace(); throw new SQLException(ex.getMessage()); } } public static Connection getConnection() throws SQLException{ //第二种加载驱动连接方法 try { Class.forName(driverName); return DriverManager.getConnection(url, user, password); } catch (Exception ex) { ex.printStackTrace(); throw new SQLException(ex.getMessage()); } } public static ResultSet select(String sql) throws SQLException{ ResultSet rs = null; Connection conn = null; try { conn = getConnection(); Statement stmt = conn.createStatement(); rs = stmt.executeQuery(sql); } catch (SQLException e) { System.out.println("查询异常:" + e.getMessage()); } finally{ if(conn != null){ conn.close(); } } return rs; }}
[解决办法]
动一点脑筋呀...只是语法不一样..楼主,稍微动一下手换过来就行了..
[解决办法]
DataSource = myserver;Database='aaa'; UID='sa';pwd='XXXX'; port='5000';charset='cp936'