这一片海,源于那一瓢水

sybase的JDBC连接

package org.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class SyBaseJDBC {
 public static void main(String[] args) {
  ResultSet rs = null;
  Statement stmt = null;
  Connection conn = null;
  String driver = "com.sybase.jdbc3.jdbc.SybDriver";
  String url = "jdbc:sybase:Tds:127.0.0.1:5000/eomsdbbk?user=develop&password=develop&useUnicode=true?CHARSET=cp936";
  // 加载驱动
  try {
   Class.forName(driver);
   conn = DriverManager.getConnection(url);
   stmt = (Statement) conn.createStatement();
   rs = stmt.executeQuery("select * from tbAddrListGrp ");
   while (rs.next()) {
    System.out.println(rs.getInt("iAddrListGrpId"));
    System.out.println(rs.getInt("iPid"));
    System.out.println(rs.getString("sName"));
    System.out.println(rs.getString("sRemark"));
   }
  } catch (ClassNotFoundException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (SQLException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } finally {
   try {
    if (rs != null) {
     rs.close();
     rs = null;
    }
    if (conn != null) {
     conn.close();
     conn = null;
    }
   } catch (Exception e) {
    e.printStackTrace();
   }
  }
 }
}

sybase的JDBC连接

posted on 2010-06-25 17:47 何方 阅读(747) 评论(0)  编辑  收藏 所属分类: java


只有注册用户登录后才能发表评论。


网站导航:
 

My Links

Blog Stats

常用链接

留言簿

随笔档案

文章分类

文章档案

相册

搜索

最新评论