HI all in Daniweb.
I have a problem here. I wanted to create a desktop database application using Java DB Embedded. What is the problem here i try creating a frame from scratch and want to connect to the database. I have create a connection to the database. it was success connection i think. but when the program loads there is a catch message table/view does not exist.
how do i fix this problem?
here is my code. in my main method
Connection con = null;
Statement cmd;
ResultSet rs;
private static String host = "jdbc:derby:comstar;create=true";
private static String uname = "";
private static String pass = "";
public void doConnect(){
try{
//connect to the database
con = DriverManager.getConnection(host, uname, pass);
//con = DriverManager.getConnection("jdbc:derby:comstar;create=true", connectionProps);
DatabaseMetaData dbmd = con.getMetaData();
//sql string
cmd = con.createStatement();
rs = dbmd.getTables(null, "APP", "STUDENT", null);
String sql = "SELECT * FROM STUDENT";
rs = cmd.executeQuery(sql);
//move to the first data
rs.next();
int id = rs.getInt("ID");
String name = rs.getString("NAME");
String matricId = rs.getString("MATRICID");
String course = rs.getString("COURSE");
String intake = rs.getString("RECRUITYEAR");
String status = rs.getString("STATUS");
String add = rs.getString("ADDRESS");
String phone = rs.getString("PHONE");
String email = rs.getString("EMAIL");
String gender = rs.getString("GENDER");
String position = rs.getString("POSITION");
//display records in text fields
idTxt.setText(Integer.toString(id));
nameTxt.setText(name);
matricTxt.setText(matricId);
courseTxt.setText(course);
intakeTxt.setText(intake);
statusTxt.setText(status);
addrTxt.setText(add);
phoneTxt.setText(phone);
emailTxt.setText(email);
genderTxt.setText(gender);
posTxt.setText(position);
}
catch(SQLException err){
JOptionPane.showMessageDialog(studentMain.this, err.getMessage());
}
}
and this is what have i imported
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.*;
import java.sql.Driver;
import java.util.Properties;
import javax.swing.JOptionPane;
import javax.swing.JFrame;
thanks a lot in advance for your help. :)