मैं एक वेब एप्लिकेशन पर काम कर रहा हूं जिसमें क्लाइंट और सर्वर साइड के बीच डेटा ट्रांसफर किया जाएगा।
मुझे पहले से ही पता है कि जावास्क्रिप्ट इंट! = जावा इंट। क्योंकि, Java int शून्य नहीं हो सकता, ठीक है। अब मेरे सामने यही समस्या है।
मैंने अपने Java int वैरिएबल को Integer में बदल दिया।
public void aouEmployee(Employee employee) throws SQLException, ClassNotFoundException
{
Integer tempID = employee.getId();
String tname = employee.getName();
Integer tage = employee.getAge();
String tdept = employee.getDept();
PreparedStatement pstmt;
Class.forName("com.mysql.jdbc.Driver");
String url ="jdbc:mysql://localhost:3306/general";
java.sql.Connection con = DriverManager.getConnection(url,"root", "1234");
System.out.println("URL: " + url);
System.out.println("Connection: " + con);
pstmt = (PreparedStatement) con.prepareStatement("REPLACE INTO PERSON SET ID=?, NAME=?, AGE=?, DEPT=?");
pstmt.setInt(1, tempID);
pstmt.setString(2, tname);
pstmt.setInt(3, tage);
pstmt.setString(4, tdept);
pstmt.executeUpdate();
}
मेरी समस्या यहाँ है:
pstmt.setInt(1, tempID);
pstmt.setInt(3, tage);
मैं यहाँ इंटेगर चर का उपयोग नहीं कर सकता। मैंने कोशिश की, intgerObject.intValue();
लेकिन यह चीजों को और अधिक जटिल बनाता है। क्या हमारे पास कोई अन्य रूपांतरण विधियाँ या रूपांतरण तकनीकें हैं?
कोई भी फिक्स बेहतर होगा।
pstmt.setInt(1, tempID.intValue())? कोड के लायक 11 वर्ण जोड़ने से आसान क्या है?