问题描述
我从。如何配置它?
至此,您只需将其放入程序的运行时类路径中,然后加载它如下所示:
中指定JDBC驱动程序JAR文件的完整路径。 code>参数,例如(针对Windows):
pre $ java -cp。; / path / to / mysql-connector-java-5.1.12。 jar com.example.YourClass
有关更多信息和提示,请查看。
更新:根据注释,您使用的是Flex,而您显然希望使用Flex在服务器上与数据库进行交互。 Flex运行在客户机上,Java + DB运行在服务器机器上。两者都通过网络与HTTP作为通信协议连接。您需要相应地在服务器端编写Java代码(Servlet?Webservice?),该代码根据HTTP请求提供的参数/ pathinfo与数据库交互,并返回所需的结果。然后,您可以调用Flex内部的HTTP请求,并处理HTTP响应。
I have downloaded MySQL JDBC driver from http://www.mysql.com/downloads/connector/j/. How do I configure it?
To the point, you just need to put it in the program's runtime classpath and then load it as follows:
try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { throw new RuntimeException("Cannot find the driver in the classpath!", e); }
If you're using an IDE, then you need to add the library to the project's Build Path. If you're running it using java.exe, then you need to specify the full path to the JDBC driver JAR file in the -cp argument, e.g. (Windows-targeted):
java -cp .;/path/to/mysql-connector-java-5.1.12.jar com.example.YourClass
For more information and hints check this small MySQL+JDBC kickoff tutorial.
Update: As per the comments, you're using Flex and you apparently want to interact with the DB at the server using Flex. Well, Flex runs at the client machine and Java + the DB runs at the server machine. Both are connected by network with HTTP as communication protocol. You need to write Java code on the server side accordingly (Servlet? Webservice?) which interacts with the DB based on the parameters/pathinfo given with the HTTP request and returns the desired results. Then you can just invoke HTTP requests from inside Flex and process the HTTP response.
这篇关于如何配置MySQL JDBC驱动程序mysql-connector-java-5.1.12?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!