07.06.2014, 11:36
First, you need the mysql connector. Put this into your pom.xml:
Then you can create a Connection instance like this:
Код:
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.30</version> </dependency>
Код:
private Connection connection; Class.forName("com.mysql.jdbc.Driver").newInstance(); connection = DriverManager.getConnection("jdbc:mysql://localhost/database", username, password); Statement stmnt = connection.createStatement(); stmnt.executeUpdate(..); ResultSet resultSet = stmnt.executeQuery(..);