关于jdbc的疑问?

baitianhai 2001-08-16 01:56:16
jdk1.3是不是自己有什么jdbc-odbc那
还是必须下载jdbc
jdbc-odbc只要设dns就行了吗?
如果不是的话,下载jdbc或jdbc-odbc怎么设置呀?(这个jdbc压缩暴力都是class文件)
我是初学者!请各位大哥大姐帮帮忙!
谢谢了!
最好能说的详细一点!
...全文
67 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
我并没有完全回答你的问题,你就把70分全给了我,受不起。你是我到目前为止遇到的给分最爽快的一个。
现把问题补答如下:

在 数据源(ODBC)增加一个名为odbcname的数据库名。
建一个连接配置文件dataresource.conf,例如:
#ODBC参数
jdbc_DBDrivers = sun.jdbc.odbc.JdbcOdbcDriver
jdbc_ConnStr = jdbc:odbc:odbcname
jdbc_USER = sa
jdbc_PASSWORD =

#联接中断时间(秒)
session_time_length = 1200

java文件如下:

import java.sql.*;
import java.io.*;

public class classname{
String sDBDriver = null;
String sConnStr = null;
String sUser = null;
String sPassword = null;

String sErrMsg=null;

String SessionTime = "1200";
String ConnFile = "dataresource.conf"; //配置文件

Connection conn = null;
ResultSet rs = null;
/**
* Sql 构造子注解。
*/
public Equipment() {
super();
this.getConnParam();
try
{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e)
{
System.err.println("sql_data(): " + e.getMessage());
}
}

private void getConnParam() {
try
{
RandomAccessFile RAfile=null; //文件对象
String line=null;
String before=null;
String after=null;
long filePoint=0;

//创建文件对象
RAfile = new RandomAccessFile(ConnFile,"r");
long length=RAfile.length();
int index=0;
while(filePoint<length)
{
line=RAfile.readLine().trim();
index=line.indexOf('=');
if (line.length()>0 && line.charAt(0)!='#' && index>0)
{
before=line.substring(0,index).trim();
after=line.substring(index+1).trim();
if (before.equals("jdbc_DBDrivers")) sDBDriver=after;
if (before.equals("jdbc_ConnStr")) sConnStr=after;
if (before.equals("jdbc_USER")) sUser=after;
if (before.equals("jdbc_PASSWORD")) sPassword=after;
if (before.equals("session_time_length")) SessionTime=after;
}
filePoint=RAfile.getFilePointer();
}
RAfile.close();
}
catch (Exception e)
{
}
}

}end class
baitianhai 2001-08-16
  • 打赏
  • 举报
回复
谢谢了,70分给你了!
  • 打赏
  • 举报
回复
jdk1.3已经包括jdbc,jdbc-odbc

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧