我是靠谱客的博主 独特汉堡,最近开发中收集的这篇文章主要介绍配置mysql的驱动程序类,如何配置MySQL JDBC驱动程序mysql-connector-java-5.1.12?,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

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的驱动程序类,如何配置MySQL JDBC驱动程序mysql-connector-java-5.1.12?的全部内容,希望文章能够帮你解决配置mysql的驱动程序类,如何配置MySQL JDBC驱动程序mysql-connector-java-5.1.12?所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部