Sql java file
From MyWiki
import java.sql.*; class Sql{ Connection conn = null; Statement stmt = null; ResultSet rs = null; void runIt() { try { String userName = "xxxxx"; String passWord = "xxxxx"; String url = "jdbc:mysql://localhost/xxxxx"; //Class.forName ("com.mysql.jdbc.Driver").newInstance (); conn = DriverManager.getConnection (url, userName, passWord); System.out.println("connection esstablsihed in Sql"); conn.close(); } catch (SQLException e){ String errorCode = e.toString(); System.out.println(errorCode); } } void runIt(String voltage) { System.out.println("The voltge in the Sql class is "+ voltage); try { String userName = "xxxxx"; String passWord = "xxxxx"; String url = "jdbc:mysql://localhost/xxxxx"; //Class.forName ("com.mysql.jdbc.Driver").newInstance (); conn = DriverManager.getConnection (url, userName, passWord); System.out.println("connection esstablsihed in Sql"); Float the_volt = Float.parseFloat(voltage); String SQL="insert into solar VALUES("+the_volt+", now())"; Statement statement = conn.createStatement(); statement.executeUpdate(SQL); conn.close(); } catch (SQLException e){ String errorCode = e.toString(); System.out.println(errorCode); } } }