html
iphone
css
xml
database
linux
ruby-on-rails
objective-c
visual-studio
eclipse
html5
perl
algorithm
cocoa
tsql
delphi
apache
mvc
php5
api
Always use PreparedStatement and Password is reserved keyword in Ms-Access.
boolean userFound=false; conn=DriverManager.getConnection("jdbc:odbc:FBS"); String sql="select [UserName],[Password] from user_login where [UserName]=? and [Password]=?"; PreparedStatement st=conn.prepareStatement(sql); st.setString1(1,userName); st.setString1(2,password); rs=st.executeQuery(); if(rs.next()) { userFound=true; } st.close(); conn.close(); if(userFound) { }
Two things jump out at me.
The first is that in the init, you should only have to call
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
without an additional "newInstance()". In fact, if you're using a JRE that supports JDBC 4.0, you shouldn't even need the "Class.forName(...)" call
The second is that you should only need the double slashes to escape forward slashes in the path. Try changing the connection string to:
conn=DriverManager.getConnection("jdbc:odbc:FBS={Microsoft Access Driver(*.accdb)};DBQ=C:\\Users\\Dumbre\\Documents\\NetBeansProjects\\Flat Booking System\\Flat_System.accdb;");
Additionally, you might try switching to a DSN, just for testing. Create a system DSN and your connection string should be:
jdbc:odbc:TheNameForTheNewDSNThatYouJustCreated
Well, obviously that last part has to be the actual name.