JDBC连接informix数据库

初步摸索informix数据库,从jdbc连接开始

1、驱动下载

https://download.csdn.net/download/ryc115/10426879

 2、代码

package java2informix;

import java.sql.*;

public class Main {

 private static String URL_STRING[] = {
//   "jdbc:informix-sqli://46.0.20.105/piccdy:INFORMIXSERVER=sd_dy"
   "jdbc:informix-sqli://46.0.20.105:20001/piccdy:INFORMIXSERVER=sd_dy;NEWCODESET=gbk,8859-1,819;IFX_USE_STRENC=true;"
 };
 
 private static String USER = "tj3705";
 private static String PASSWORD = "tj3705";
  
 public static void main(String[] args) throws SQLException, ClassNotFoundException{
  
  Connection conn;
  Class.forName("com.informix.jdbc.IfxDriver");
  
  for (int i = 0; i < 2; i++) {
   try {
    System.out.println("Testing JDBC URL: " + URL_STRING[i]);
    conn = DriverManager.getConnection(URL_STRING[i], USER, PASSWORD);
    System.out.println("connect successfully");
    conn.close();
    } catch( Exception e) {
     e.printStackTrace();
    }
   }
  return;
 }
}

 

3、URL连接地址,查看DBVisualizer

JDBC连接informix数据库_第1张图片

 

 

 

 

 

 

你可能感兴趣的:(jdbc,informix,数据库)