当前位置:Gxlcms > 数据库问题 > jdbc

jdbc

时间:2021-07-01 10:21:17 帮助过:13人阅读

    连接字符串 url比如oracle就是jdbc:oracle:thin:@localhost:1521:orcl 1. Oracle url示例:"jdbc:oracle:thin:@localhost:1521:orcl"
2. Access url示例:"jdbc:odbc:HANFENG"
3. SQL Server url示例:"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs"
4. DB2 url示例:"jdbc:db2://localhost:5000/sample"
5. Informix url示例:"jdbc:informix-sqli://123.45.67.89:1533/testDB:INFORMIXSERVER=myserver"
6. Sybase url示例:"jdbc:sybase:Tds:localhost:5007/tsdata"
7. MySQL url示例:"jdbc:mysql://localhost/softforum?user=soft&password=soft1234& amp;useUnicode=true&characterEncoding=8859_1"
8. PostgreSQL url示例:"jdbc:postgresql://localhost/soft"   要指明数据库的名字 执行select语句要用executeQuery(“”),结果保存到ResultSet 中去。 rs.getString("name")获得name字段里的一条记录,返回一个string
  执行结束了要把他们都关掉,写在finally里面。 PreparedStatement可以灵活指定sql语句中变量的statement    pstmt = conn.prepareStatement("insert into student values(?,?)");    pstmt.setString(1, "sdf");    pstmt.setString(2, "ss");    pstmt.executeUpdate(); 这样有利于变量类型的控制,用的比较多。                  

jdbc

标签:final   log   classpath   oracle   空间   print   family   color   tco   

人气教程排行