按照我的写法行不通啊.
能否帮我改改???
<%
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try
{
Class.forName("sun.jdbc.odb.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{ } try
{
con=DriverManager.getConnection("jdbc:odbc:sun");
stmt=con.createStatement(); File file=new File("F:/JavaFile","text.txt");
FileReader filein=new FileReader(file);
BufferedReader bufferin=new BufferedReader(filein);
int k=1;
String[]option=new String[7];
String temp=null,
str=null;
String contion=null;
StringTokenizer tokenizer=null;
String logname=null,
realname=null; while((str=bufferin.readLine())!=null)
{
temp=str;
out.print("<br>"+temp);
tokenizer = new StringTokenizer(temp);
}
while(tokenizer.hasMoreTokens())
{
option[k]=tokenizer.nextToken();
k++;
logname=option[1];
realname=option[2];
String condition=" INSERT INTO user VALUES ( "+"'"+logname+"','"+realname+"'"+")";
stmt.executeUpdate(condition); } rs=stmt.executeQuery(" SELECT * FROM USER ");
bufferin.close();
con.close();
out.println("<h2>"+"Ok!"+"</h2>");
}
catch(IOException e1)
{
out.println("<h2>"+"No!"+"</h2>");
}%>
能否帮我改改???
<%
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try
{
Class.forName("sun.jdbc.odb.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{ } try
{
con=DriverManager.getConnection("jdbc:odbc:sun");
stmt=con.createStatement(); File file=new File("F:/JavaFile","text.txt");
FileReader filein=new FileReader(file);
BufferedReader bufferin=new BufferedReader(filein);
int k=1;
String[]option=new String[7];
String temp=null,
str=null;
String contion=null;
StringTokenizer tokenizer=null;
String logname=null,
realname=null; while((str=bufferin.readLine())!=null)
{
temp=str;
out.print("<br>"+temp);
tokenizer = new StringTokenizer(temp);
}
while(tokenizer.hasMoreTokens())
{
option[k]=tokenizer.nextToken();
k++;
logname=option[1];
realname=option[2];
String condition=" INSERT INTO user VALUES ( "+"'"+logname+"','"+realname+"'"+")";
stmt.executeUpdate(condition); } rs=stmt.executeQuery(" SELECT * FROM USER ");
bufferin.close();
con.close();
out.println("<h2>"+"Ok!"+"</h2>");
}
catch(IOException e1)
{
out.println("<h2>"+"No!"+"</h2>");
}%>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货