Java Program එකකට කොහොමද Access 2007 හදපු DB එකක් Connect කරලා, පාස්වර්ඩ් එකක්දෙන්නෙ? ඩේටාබෙස් එකේ පාස්වර්ඩ් එක..
පාස්වර්ඩ් නැතුව එකක් හැදුවා.. පොඩ්ඩක් බලන්න... මේකට තමයි Password ඕන...
පාස්වර්ඩ් නැතුව එකක් හැදුවා.. පොඩ්ඩක් බලන්න... මේකට තමයි Password ඕන...
Code:
package javaapplication1;
import java.sql.*;
public class JavaApplication1 {
public static void main(String[] args){
// TODO code application logic here
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Driver={Microsoft Access Driver " +
"(*.mdb, *.accdb)};DBQ=C:\\BBB\\Database11.accdb"; // Installing Driver and Pointing DB
Connection con = DriverManager.getConnection(url);
System.out.println("Connected!");
Statement stmt =null ;
String SQL = "INSERT INTO Names(ID,first_name,last_name) VALUES ('4','s3cv','k2amala')";
stmt = con.createStatement();
int i = stmt.executeUpdate(SQL);
if (i != 0){
System.out.println("Data update succeded");
}
else
System.out.println("Data update error");
con.close();
} catch (SQLException e) {
System.out.println("SQL Exception: "+ e.toString());
} catch (ClassNotFoundException cE) {
System.out.println("Class Not Found Exception: "+
cE.toString());
}
// SQL INSERT command
}
}
Last edited: