我正在研究 java JDK7 和 Microsoft Access 2007。基本上我想从 row1 的所有列中获取最小值。但是下面的代码不起作用。
import java.io.*;
import java.util.*;
import java.net.*;
import java.sql.*;
public class server
{
public void check()
{
int min = 100, row = 0, index, i = 2;
try {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn = DriverManager.getConnection("jdbc:odbc:DSN2");
Statement st = cn.createStatement();
ResultSet rs = st.executeQuery("select *from Table1");
rs.next();
System.out.println(rs.getInt(1) + "\t" + rs.getInt(2) + "\t" + rs.getInt(3) + "\t" + rs.getInt(4) + "\t" + rs.getInt(5) + "\t" + rs.getInt(6));
for (i = 2; i < 7; i++)
{
System.out.println("hello");
if (rs.getInt(i) < min) {
index = i;
min = rs.getInt(i);
}
}
} catch (Exception e) {
e.getMessage();
}
switch (i) {
case 2:
ioConnect();
break;
case 3:
break;
case 4:
ioConnect();
break;
case 5:
ioConnect();
break;
case 6:
ioConnect();
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void ioConnect() {
try {
ServerSocket ss = new ServerSocket(2000);
Socket so = ss.accept();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the message");
String str = br.readLine();
PrintStream ps = new PrintStream(so.getOutputStream());
ps.println(str);
} catch (Exception e) {
e.getMessage();
}
}
}
class serverm {
public static void main(String s[]) {
servern obj = new servern();
obj.check();
}
}
所以在这里我得到输出的第一行每列的值很好,但是当控件进入for循环时,println语句只打印一次hello并且光标闪烁。这表明程序没有正确结束。