Board index » jbuilder » create a odbc alias in Java

create a odbc alias in Java


2003-11-26 09:07:28 PM
jbuilder2
Is it possible to create/delete/modify a ODBC alias in Java?
 
 

Re:create a odbc alias in Java

import java.sql.*;
import java.lang.*;
public class ejdbcsel {
public static void main(String args[]) {
// eric_jsp is ODBC User DNS
// String url = "jdbc:odbc:eric_jsp";
// Using DSNless connection
String url = "";
url = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)}"
+";SERVER=127.0.0.1;DBQ=m:\\data\\maximo\\maxdata\\chief.mdb";
Connection con;
String query;
//query = "SELECT * FROM COUNTR";
query = "select * from equip";
Statement stmt;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e) {
System.err.print("ClassNotFoundException " );
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection (url,"","");
stmt = con.createStatement();
ResultSet rec = stmt.executeQuery(query);
// Scan the Database
while(rec.next()) {
System.out.println(rec.getString(2) + "\t"
+ rec.getString(1));
}
stmt.close();
con.close();
} catch (SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
catch (Exception e) {
System.err.println("Error: " + e.toString() + " " + e.getMessage());
}
}
}
"xasco" < XXXX@XXXXX.COM >wrote in message
Quote
Is it possible to create/delete/modify a ODBC alias in Java?