-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
unknown
committed
Dec 10, 2015
0 parents
commit afc83ee
Showing
5 changed files
with
658 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Jmysconnection | ||
Copyright 2015 The TEENET Organization | ||
Produce by TEENET technology (teenet.me) | ||
|
||
Jmysconnection is an Java API for connecting Mysql databases. | ||
This API rely on mysql-connector-java-5.1.6-bin.jar. (Shown in folder) | ||
|
||
How To Use: | ||
Move "jmysconnection" folder to your project, and import jmysconnection.Mysql to your class. | ||
Move mysql-connector-java-5.1.6-bin.jar to your project. | ||
Modify the configuration file (Configuration.java) first, and ensure the connection is correct. | ||
Then you can start to using it. | ||
|
||
This API only support "int","String","Timestamp" data type. | ||
This API has not prepare for SQL injecting protection. | ||
|
||
We have Chinese note in this API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Jmysconnection | ||
Copyright 2015 The TEENET Organization | ||
Produce by TEENET technology (teenet.me) | ||
|
||
Jmysconnection是一个用于JAVA连接MYSQL的接口 | ||
此接口需要依赖于mysql-connector-java-5.1.6-bin.jar包。 | ||
|
||
如何使用: | ||
复制”jmysconnection“文件夹到你的工程,然后在所需要使用此接口的java类中导入”import jmysconnection.Mysql“ | ||
复制mysql-connector-java-5.1.6-bin.jar到你的工程 | ||
修改此接口的配置文件(Configuration.java)且确保连接参数正确 | ||
然后你就可以开始用了 | ||
|
||
此接口仅支持”int“、”String“、”Timestamp“数据类型 | ||
此接口并没有设置防范SQL注入 | ||
|
||
接口注释中已包含中文注释 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package jmysconnection; | ||
|
||
import java.sql.DriverManager; | ||
import java.sql.SQLException; | ||
|
||
import com.mysql.jdbc.Connection; | ||
|
||
public class Configuration { | ||
/** | ||
* @author Jerry_P | ||
* | ||
* <p> | ||
* JMysConnection Version V0.1.1 | ||
* </p> | ||
* | ||
* <p> | ||
* 使用前,先在这里设置一下数据库信息 | ||
* </p> | ||
* <p> | ||
* 请将连接驱动包:mysql-connector-java-5.1.6-bin.jar导入。 | ||
* </p> | ||
* <p> | ||
* Before using, place configurate following terms | ||
* </p> | ||
* <p> | ||
* Place input the connection driver's package:mysql-connector-java-5.1.6-bin.jar | ||
* </p> | ||
*/ | ||
public static Connection getConn() { | ||
String driver = "com.mysql.jdbc.Driver"; | ||
String addr = "localhost"; //这里输入数据库地址 Input your database address here | ||
String databaseName = "name"; // 这里输入数据库名 Input your database name here | ||
String port = "3306"; // 这里输入端口 Input your database port here | ||
String username = "root"; // 这里输入数据库用户名 Your Mysql username | ||
String password = "password"; // 这里输入数据库密码 Your Mysql password | ||
String url = "jdbc:mysql://" + addr + ":" + port + "/" + databaseName; | ||
Connection conn = null; | ||
try { | ||
Class.forName(driver); | ||
conn = (Connection) DriverManager.getConnection(url, username, password); | ||
} catch (ClassNotFoundException e) { | ||
e.printStackTrace(); | ||
} catch (SQLException e) { | ||
e.printStackTrace(); | ||
} | ||
return conn; | ||
} | ||
} |
Oops, something went wrong.