+ 2
Email ID
I wan to insert the user Id as email id to my database through the java netbeans text field can anyone help me?
2 ответов
+ 6
first of all add SQL library to your project. go to project section in netbeans and then right click on the libraries folder. Click on add library option. select your desired library. then write this code where you want to write it
import java.sql.*;
.
.
String userid=jTextField1.getText();
try{
Class.forName("java.sql.DriverManager");
Connection conn=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/project_name","mysql_password","mysql_password");
Statement stmt=(Statement)conn.createStatement();
String sql="insert into database_name(emailid) value ("+userid+");";
stmt.executeUpdate(sql);
stmt.close();
conn.close();
}
catch(Exception e)
{
System.out.println(e);
}
0
sure,
you need JDBC and driver installed then you can use preparef statement to execute your sql query.