Last active
August 5, 2016 04:58
-
-
Save 64lines/80b0083db7f837c796ab36699b58f78e to your computer and use it in GitHub Desktop.
Java Database Connection to MySQL
This file contains hidden or 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
| String URL = "jdbc:mysql://localhost:5004/test"; | |
| try { | |
| Connection conn = DriverManager.getConnection (URL, "username", "password"); | |
| Statement statement = conn.createStatement(); | |
| ResultSet resultSet = statement.executeQuery("select * from tweet_post;"); | |
| while(resultSet.next()) { | |
| System.out.println(resultSet.getString("id") + "\t" + resultSet.getString("tweet")); | |
| } | |
| } catch (SQLException ex) { | |
| Logger.getLogger(Babylon.class.getName()).log(Level.SEVERE, null, ex); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment