通过命令行在Java中设置ODB连接 [英] Setting up ODB Connection in Java via Command Line

查看:235
本文介绍了通过命令行在Java中设置ODB连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用Java创建了一个登录程序.它使用具有两个字段(用户名和密码)的数据库.该程序访问数据库并从两个字段中检索记录.它在将ODBC服务器地址设置为192.168.1.4并已打开端口的计算机上运行.但是,我需要知道如何通过cmd行创建ODB连接,但又如何从Java应用程序访问cmd行.以及如何在使用MySQL时将驱动程序添加到ODBC文件夹,这是必需的还是可以使用文件中的SQL Server驱动程序代替.

登录程序的代码如下

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 below

	public 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.

推荐答案

无命令行-您应该使用适当的JDBC连接.

关于JDBC的教程 [
no command line - you should use a proper JDBC-Connection.

Tutorial on JDBC[^]


这篇关于通过命令行在Java中设置ODB连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆