import java.sql.*;
public class p
{
public static void main(String[] args)
{
String sql;
Connection conn;
Statement stmt;
ResultSet rs;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:student";
String user="sa";
String password="";
conn= DriverManager.getConnection(url,user,password);
stmt=conn.createStatement();
sql="select * from student";
rs=stmt.executeQuery(sql);
while(rs.next())
{
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
}
rs.close();
stmt.close();
conn.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
这个中student数据库是默认路径的,可以换路径吗?怎么换?
------解决方案--------------------------------------------------------
用的什么数据库?