java使用cmd连接数据库,通过命令行在Java中设置ODB连接

I have created a login program in Java. It uses a database with two fields (Username and Password). The program accesses the database and retrieves the records from the two fields. It works on my computer with the ODBC server address being set to 192.168.1.4 and the ports have been opened. However I need to know how I can create a ODB Connection via cmd line but having it access the cmd line from the Java application. And also how do I add a driver to the ODBC folder as I am using MySQL and is this needed or could I use the SQL Server driver that is in the files instead.

The code for the Login program is belowpublic static void main(String[] args)

{

if (ConnectionSetup = true)

{

//Do Nothing

}

else if (ConnectionSetup = false)

{

SetupConnection();

}

new Login();

}

public static void SetupConnection()

{

//The code for the command line would go here

}

}

Can somebody please help me because I have tried everything that I know. Thanks in advance.

解决方案

no command line - you should use a proper JDBC-Connection.

Tutorial on JDBC[^]