我有一个问题,我认为有人可能会帮助我,因为我有点困惑。我制作了一个程序,我正在读取 excel 文件并将它们的数据存储在数据库中。在这个数据库中,每个 excel 文件都创建一个表。我已经制作了程序,到目前为止一切正常。现在,在我完成连接之后,我希望用户能够提供将在客户端中读取的文件的完整路径,然后继续执行程序的其余部分,读取数据并将它们存储在桌子。任何人都可以帮助我如何做到这一点?下面是连接代码。
public static void main (String[] args) throws Exception {
try {
System.out.println("get the connection");
}
catch( Exception e )
{
System.out.println( "SQLException: " + e.getMessage() );
}
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection) DriverManager.getConnection(
"jdbc:mysql://localhost:3306/kainourgia", "root", "root");
DatabaseMetaData meta = (DatabaseMetaData) con.getMetaData();
ResultSet res = meta.getCatalogs();
System.out.println("List of the databases: ");
while (res.next()){
System.out.println (" " +res.getString(1));
}
//String filename = "C:\\Users\\myfiles\\Documents\\test5.xls";
String fullPath = "C:\\Users\\myfiles\\Documents\\test5.xls";
String Path = "C:\\Users\\myfiles\\Documents\\";
String filename = "test5.xml";
String[] parts = filename.split("\\.");
String tablename = parts[0];
有人可以帮我吗?