java - trying to read data from textfile - It is already opened exclusively by another user, or you need permission to view its data -
public class txt { public static void main(string[] args) throws exception { class.forname("sun.jdbc.odbc.jdbcodbcdriver"); connection con=drivermanager.getconnection("jdbc:odbc:txt"); statement st=con.createstatement(); resultset rs=st.executequery("select eno,ename emp"); system.out.println(rs.getint(1)+" "+rs.getstring(2)); } }
you should close connection on end of code;
con.close(); use example:
public static void main(string[] args) throws exception { seek { class.forname("sun.jdbc.odbc.jdbcodbcdriver"); connection con=drivermanager.getconnection("jdbc:odbc:txt"); statement st=con.createstatement(); resultset rs=st.executequery("select eno,ename emp"); system.out.println(rs.getint(1)+" "+rs.getstring(2)); } grab (sqlexception e) { e.printstacktrace(); } grab (exception e) { e.printstacktrace(); } { // close connection con.close(); } } good luck!
java jdbc
No comments:
Post a Comment