/** * */ package DatabaseConnection; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; /** * @author satyanarayanagokavarapu * */ public class MySqlConnectionExample { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub // creates three different Connection objects Connection conn2 = null; try { String url2 = "jdbc:mysql://localhost:3306/soccer? user=root&password=mysql123"; conn2 = DriverManager.getConnection(url2); if (conn2 != null) { System.out.println("Connected to the database soccer"); } } catch (SQLException ex) { System.out.println("An error occurred. Maybe user/password is invalid"); ex.printStackTrace(); } } }
Sample JDBC Connection Example JAVA,JDBC,MYSQL
Subscribe to:
Post Comments (Atom)
Featured Post
H1B Visa Stamping at US Consulate
H1B Visa Stamping at US Consulate If you are outside of the US, you need to apply for US Visa at a US Consulate or a US Embassy and get H1...
-
Ques 1 : Which declaration of the main method below would allow a class to be started as a standalone program. (A) public static int main(c...
-
1. Two Sum Two Sum Solution 2. LRU Cache LRU Cache Solution 3. Number Of Islands 4. Longest Palindromic Substring 5. Lowest...
-
basics Linux fundamentals like system calls , strace , linux mange memory, shared memory, kernel using, boot process, DNS resolving ( how t...
No comments:
Post a Comment