Missing parameter in Jdbc Ms access connection
hi everybody?
how are you doing?
i have a small problem
i hope helps me get rid of it
the problem is:
i wrote a servlet which makes a connection to an MS access database and retreives a data.
I am having an exception saying that one parameter is missing ?Can someone tell me what is wrong with this code? Thanks :)
here is the code snippet:
import java.io.*;
import java.sql.*;
public class dbconn {
Connection con = null;
String user="yilmaz";
String username,userpassword="";
String sql="select pass from members where user='yilmaz'";
Statement st=null;
ResultSet rs=null;
//public String main(St
public String connectDatabase() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:focus&userid=&password=");
st=con.createStatement();
rs=st.executeQuery(sql);
while(rs.next()) {
username=rs.getString(1);
userpassword=rs.getString(2); }
return userpassword;
} catch (SQLException e) {
System.out.println("Could not connect database :"+e.getMessage());
return userpassword;
}
catch (IOException ioe) {System.out.println(" IOexception "+ioe.getMessage()); }
}
public void closeConnection() {
try {
if (con != null)
con.close();
} catch (Exception e){
System.out.println("error: can not close database connection"+e.getMessage());
}
}
}

