• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdbc advanced

 
joseph jacob
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i connect directly to msaccess database .if yes how
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there are a whole bunch of replies like this, but here is one http://www.javaranch.com/ubb/Forum3/HTML/001275.html
Dave
 
Dorj Galaa
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u must create ODBC DSN
java sample
import java.sql.*;
String url="jdbc dbc:yourodbcdsn";
int Recordcount=0;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection access=DriverManager.getConnection(url,"Admin","");
Statement st=access.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
String Query="select * from table1";
ResultSet Result=st.executeQuery(Query);
Result.last();
RecordCount=Result.getRow();
Ssytem.out.println(RecordCount);
Result.close();
st.close();
access.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic