How to connect MySQL, Oracle, SQL Server database JDBC mysql: add a MySQL jar package first String url= "jdbc:mysql://localhost:3306/database name"; //Database address String name= "root"; //database user name String password= "123456"; // Database user Password Class.forName ("Com.mysql.jdbc.Driver"); //load MySQL driver Connection conn = Drivermanager.getconnection ( Url,name,passWOrd); //Connection Database Oracle: Add Oracle's JAR package String url= "Jdbc:oracle:thin: @localhost: 1521: Database Name"; //Database address String name= "Database user name"; //database user name String password= "database user password"; / /database user Password Class.forName ("Oracle.jdbc.driver.OracleDriver"); //load Oracle Drive Connection conn = Drivermanager.getconnection (URL,Name,password); //Connection Database sql server: Add a jar package for SQL Server String url= "jdbc:sqlserver://localhost:1433;databasename= database name"; // Database Address sring name= "Database username"; //database user name String Password = "Database user password"; //database user password Class.forName (" Com.microsoft.sqlserver.jdbc.SQLServerDriveR "); //Load SQL Server driver Connection conn = Drivermanager.getconnection ( Url,name,password); //Connection database
How to connect MySQL, Oracle, SQL Server database JDBC