Click here to Skip to main content
15,884,177 members
Home / Discussions / Java
   

Java

 
AnswerRe: how to write the console output to text file? Pin
Richard MacCutchan18-Aug-16 0:36
mveRichard MacCutchan18-Aug-16 0:36 
Generalhow to print the fullstr string to a text file. Pin
Member 1142765716-Aug-16 0:39
Member 1142765716-Aug-16 0:39 
GeneralRe: how to print the fullstr string to a text file. Pin
Member 1142765716-Aug-16 0:44
Member 1142765716-Aug-16 0:44 
GeneralRe: how to print the fullstr string to a text file. Pin
Richard MacCutchan16-Aug-16 1:22
mveRichard MacCutchan16-Aug-16 1:22 
SuggestionRe: how to print the fullstr string to a text file. Pin
Richard Deeming16-Aug-16 2:10
mveRichard Deeming16-Aug-16 2:10 
GeneralRe: how to print the fullstr string to a text file. Pin
Richard MacCutchan16-Aug-16 2:58
mveRichard MacCutchan16-Aug-16 2:58 
Questionneed to print the fullstr string to a textfile Pin
Member 1142765716-Aug-16 0:31
Member 1142765716-Aug-16 0:31 
QuestionDuplicate entry 'VALUE' for key 'PRIMARY' Pin
Django_Untaken13-Aug-16 9:54
Django_Untaken13-Aug-16 9:54 
Hello there. I am trying to insert record into MySQL table. Record gets inserted but I am getting this weird exception. Here is my code
// Register JDBC driver
Class.forName(JDBC_DRIVER);

// Open a connection
m_MySqlConnection = DriverManager.getConnection(DB_URL, USER, PASS);

PreparedStatement add_emp_prepstmt = m_MySqlConnection.prepareStatement("INSERT INTO EmployeeDetails VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
add_emp_prepstmt.setString(1, emp.EmployeeId);
add_emp_prepstmt.setString(2, emp.Password);
add_emp_prepstmt.setString(3, emp.FirstName);
add_emp_prepstmt.setString(4, emp.SurName);
add_emp_prepstmt.setInt(5, emp.Age);
add_emp_prepstmt.setInt(6, emp_sex_id);
add_emp_prepstmt.setString(7, emp.Address);
add_emp_prepstmt.setString(8, emp.City);
add_emp_prepstmt.setInt(9, emp_maritalstatus_id);
add_emp_prepstmt.setString(10, emp.EmailId);
add_emp_prepstmt.setInt(11, emp_type_id);
add_emp_prepstmt.setInt(12, emp_department_id);
add_emp_prepstmt.setString(13, emp.Designation);
add_emp_prepstmt.setDouble(14, emp.Salary);
add_emp_prepstmt.setString(15, emp.NTN);
add_emp_prepstmt.setDouble(16, emp.TaxPercent);

add_emp_prepstmt.executeUpdate(); // HERE EXCEPTION OCCURS
And following is the exception showing

<br />
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'muzammil-XYZ-1235' for key 'PRIMARY'<br />


with tons of locations afterwards. Last line of code snippet shows exact exception location. Agaiiiin, record gets inserted. What could be wrong?? Thanks.
AnswerRe: Duplicate entry 'VALUE' for key 'PRIMARY' Pin
Patrice T13-Aug-16 16:59
mvePatrice T13-Aug-16 16:59 
GeneralRe: Duplicate entry 'VALUE' for key 'PRIMARY' Pin
Django_Untaken14-Aug-16 3:28
Django_Untaken14-Aug-16 3:28 
GeneralRe: Duplicate entry 'VALUE' for key 'PRIMARY' Pin
Patrice T14-Aug-16 3:39
mvePatrice T14-Aug-16 3:39 
Question[SOLVED] java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Pin
Django_Untaken4-Aug-16 8:35
Django_Untaken4-Aug-16 8:35 
AnswerRe: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Pin
Richard MacCutchan4-Aug-16 20:38
mveRichard MacCutchan4-Aug-16 20:38 
QuestionMaven cmd line Tests failing,M aven Test Run Through Eclipse Pass Pin
DLamar123-Aug-16 8:29
DLamar123-Aug-16 8:29 
AnswerRe: Maven cmd line Tests failing,M aven Test Run Through Eclipse Pass Pin
jschell12-Aug-16 10:54
jschell12-Aug-16 10:54 
Questionread and traverse over the TTL file Pin
Eng.Roqaya22-Jul-16 8:12
Eng.Roqaya22-Jul-16 8:12 
AnswerRe: read and traverse over the TTL file Pin
Richard MacCutchan22-Jul-16 21:25
mveRichard MacCutchan22-Jul-16 21:25 
Question.jar to .exe Pin
prateek chauhan19-Jul-16 18:47
prateek chauhan19-Jul-16 18:47 
AnswerRe: .jar to .exe Pin
Richard MacCutchan19-Jul-16 21:48
mveRichard MacCutchan19-Jul-16 21:48 
AnswerRe: .jar to .exe Pin
Afzaal Ahmad Zeeshan22-Jul-16 8:33
professionalAfzaal Ahmad Zeeshan22-Jul-16 8:33 
AnswerRe: .jar to .exe Pin
Curry Francis25-Jul-16 1:50
Curry Francis25-Jul-16 1:50 
GeneralRe: .jar to .exe Pin
Richard MacCutchan25-Jul-16 3:16
mveRichard MacCutchan25-Jul-16 3:16 
GeneralRe: .jar to .exe Pin
Curry Francis27-Jul-16 4:01
Curry Francis27-Jul-16 4:01 
GeneralRe: .jar to .exe Pin
Richard MacCutchan27-Jul-16 4:51
mveRichard MacCutchan27-Jul-16 4:51 
GeneralRe: .jar to .exe Pin
jschell12-Aug-16 10:58
jschell12-Aug-16 10:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.