Click here to Skip to main content
15,908,115 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Java
{
    
    Connection connect = null;
    Statement statement = null;
    PreparedStatement preSt = null;
    ResultSet resultSet = null;
       
    String url = "jdbc:mysql://localhost:3306/";
		  String dbName = "mydb";
		  String driver = "com.mysql.jdbc.Driver";
		  String userName = "root"; 
		  String password = "promod";
		  try {
		  Class.forName(driver).newInstance();
		  Connection conn = DriverManager.getConnection(url+dbName,userName,password);
		  Statement st = conn.createStatement();
//		  ResultSet res = st.executeQuery("SELECT * FROM mydb");
//		  while (res.next()) {
//		  int id = res.getInt("id");
//		  String msg = res.getString("msg");
//		  System.out.println(id + "\t" + msg);
//		  }
		  int val = st.executeUpdate("INSERT into mydb VALUES("+","+""+")");
		  if(val==1)
			  System.out.print("Successfully inserted value");
		  conn.close();
		  } catch (Exception e) {
		  e.printStackTrace();
		  }



i have created a database using mysql
and it has id, pass_no,Cntry_Name, Csa_Name, Visa_Name, Sub_Date, Col_Date

Id will generate automatically

others we have to input manually to java desktop ui.
Posted
Comments
Richard MacCutchan 3-Sep-14 7:44am    
You need to read the values from somewhere. Either from a list in a file, or as inputs from the user.
Hemas Ilearn 5-Sep-14 3:40am    
yes i'm getting values from users through input boxes......

1 solution

check your database name and table name. what is the database name and table name that you given into the connection of the mysql
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900