Created
July 25, 2017 14:15
-
-
Save Dwiga/e7662d2a67820873d17207953f96134c to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package digital_scale; | |
/** | |
* | |
* @author riyos | |
*/ | |
import java.sql.*; | |
import javax.swing.JOptionPane; | |
public class javaconnect { | |
Connection conn=null; | |
public static Connection ConnectDB(){ | |
try | |
{ | |
Class.forName("com.mysql.jdbc.Driver"); | |
Connection conn = DriverManager.getConnection("jdbc:mysql://192.168.1.39/db_name","username", "password"); | |
return conn; | |
} | |
catch (Exception e) | |
{ | |
JOptionPane.showMessageDialog(null, e); | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment