Skip to content

Instantly share code, notes, and snippets.

@Dwiga
Created July 25, 2017 14:15
Show Gist options
  • Save Dwiga/e7662d2a67820873d17207953f96134c to your computer and use it in GitHub Desktop.
Save Dwiga/e7662d2a67820873d17207953f96134c to your computer and use it in GitHub Desktop.
/*
* 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