classes:general:dbsamples:java_mysql
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
classes:general:dbsamples:java_mysql [2020/10/26 12:22] – created localadmin | classes:general:dbsamples:java_mysql [2020/11/02 09:03] (current) – localadmin | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | For Java database connections you will need to add the proper JDBC library to your project or classpath. | ||
+ | |||
+ | < | ||
import java.sql.Connection; | import java.sql.Connection; | ||
import java.sql.DriverManager; | import java.sql.DriverManager; | ||
Line 11: | Line 14: | ||
public static void main(String[] args) { | public static void main(String[] args) { | ||
- | String url = " | + | |
- | String user = "olympiad"; | + | |
- | String password = "B6pLyr49"; | + | String user = "remoteUser"; |
+ | String password = "bigsecurepassword"; | ||
- | String query = " | + | String query = " |
+ | | ||
+ | | ||
- | try (Connection | + | try (Connection |
- | Statement st = con.createStatement(); | + | Statement st = conn.createStatement(); |
ResultSet rs = st.executeQuery(query)) { | ResultSet rs = st.executeQuery(query)) { | ||
Line 33: | Line 39: | ||
} | } | ||
} | } | ||
+ | </ |
classes/general/dbsamples/java_mysql.1603732932.txt.gz · Last modified: 2020/10/26 12:22 by localadmin