JDBC ODBC System vs User DSN
Hi... I've got an Acees db setup as a User DSN source. When I acees this source off of this machine with a java executable ( one with a main method), no problems. When I put the exact same connection code into a JSP page, I get the following error...
SQLException : [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Is this error because I'm accessing the JSP through a server which resides on another machine and so doesn't see the User DSN source? If so, how do I create a System DSN? I'm on a university intranet here and they don't allow us to do anything (or maybe I'm just bad :D) On the university's intranet page it does say the following...
"DATABASE support (System DSN called 0014157, access 2000 database in database folder)"
But eh, like, er, how do I write the connection line then? Do I just stick my database into the database folder and er, like, then, er, what... ?
All and any help appreciated... merry christmas.
import java.sql.*;
public class Test {
public static void main (final String [] args) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection ("jdbc:odbc:217cw");
Statement stmt = con.createStatement();
ResultSet res = stmt.executeQuery ("SELECT ImageUrl FROM Weapons");
while (res.next ()) {
System.out.println (res.getString ("ImageUrl"));
catch (final SQLException sqe) {
System.out.println (sqe.getMessage ());
catch (final ClassNotFoundException cnfe) {
System.out.println (cnfe.getMessage ());
}
Commonly system DSNs are recommended rather than user DSNs.
How to make them:
my control panel for ODBC has a tab folder "user DSN" and another one "system DSN". Each shows a list of existing DSNs of that type and offers a button to create a new one of that type.
Similar Messages
-
I have a MS Access database which I want to connect to dynamicly using JDBC-ODBC bridge and without having to create a new record for the database in the DSN.
Usually the code looks like this
// Load the JDBC-ODBC bridge driver
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
// ODBC data source name
String dsn = "jdbc:odbc:AccessTest";
String user = "admin";
String password = "";
con = DriverManager.getConnection(dsn, user, password);
...But since the position or name of the database is always changing I would like have it something like this
String pathToDatabase = "c:\temp\database.mdb";
// Load the JDBC-ODBC bridge driver
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
// ODBC data source name
String dsn = "jdbc:odbc:" + pathToDatabase;
String user = "admin";
String password = "";
con = DriverManager.getConnection(dsn, user, password);
...I hope you know where I'm going with this and if you know the answer to.
Thxsearch for "dynamic dsn" in this forum.
-
Cannot see System DSN ODBC Data source (however user DSN is Ok)
We have installed BO 6.5.1 on Windows 2008 R2 64 bit and set up ODBC Data source to the existing SQL server.
When we try to set the BO up (Administration>Safe recovery etc.), in the "Database middleware selection" - "Define new connection" - "Data source name" we cannot see the System DSN name that we've created in the Window's "ODBC data source administration" control panel applet. If we create a User DSN, we can see it ok but it works for one user only (as it should).
So, in a nutshell, if we setup a User DSN it works fine but if we setup a system-wide System DSN BO cannot see it. I've got no idea why...
Can anyone point me to the right direction, please?Are you using the ODBC Administrator from control panel? If so, try launching this instead: odbcad32.exe from start/run.
This is the 32-bit ODBC administrator and since we are a 32-bit application, a 32-bit DSN will need to be configured.
Here's another forum thread that may be helpful:
http://social.msdn.microsoft.com/Forums/en/sqldataaccess/thread/49e206c3-f4f8-4757-8990-71b93120d2bc
and this one too:
http://forums.techarena.in/windows-x64-edition/698703.htm
Thanks
Jonathan -
Cannot access remote FoxPro dbf file using jdbc-odbc and system DSN
Hi all,
I have a foxpro database sitting on remote server (netware server). the dbf folder is shared and I can access it using windows explore on my weblogic server (windows 2003). I created a system dsn for that. I can access the database from the a stand alone java program using
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection surgConn = DriverManager.getConnection("jdbc:odbc:FoxDB", " ", " ");
But when I use the same thing in my weblogic 8.1 application, I cannot access the database. I didn't config any data source in weblogic 8.1
Why?
When I try this on my own computer - windows 2000, weblogic 8.1 workshop. remote foxpro database dbf folder. it works.
Any idea?
Thanks very muchLaura Ren wrote:
Hi all,
I have a foxpro database sitting on remote server (netware server). the dbf folder is shared and I can access it using windows explore on my weblogic server (windows 2003). I created a system dsn for that. I can access the database from the a stand alone java program using
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection surgConn = DriverManager.getConnection("jdbc:odbc:FoxDB", " ", " ");
But when I use the same thing in my weblogic 8.1 application, I cannot access the database.What exception do you get? WebLogic is just like any other Java App. That code
should work OK (though I have a better way)... Be warned that the JDBC ODBC
bridge is specifically dangerous. It is not threadsafe.
Joe
I didn't config any data source in weblogic 8.1
Why?
When I try this on my own computer - windows 2000, weblogic 8.1 workshop. remote foxpro database dbf folder. it works.
Any idea?
Thanks very much -
FILE DSN using JDBC-ODBC Bridge ?
Please Give Me sample code for Making connection
against a dbms using FILE DSN & JDBC ODBC BridgeWhat do you mean by FILE DSN? Can you be a little more specific?
-
Novice user...jdbc vs. jdbc-odbc
Hi
What are the differences between using a jdbc driver and the jdbc-odbc bridge??
Is is acceptable to use the jdbc-odbc bridge for web application. have u used it? If so, what were the negatives pointers of using the jdbc-odbc bridge on a live web application??
what is JTA/JTS?
any input will do...thanx in advance..
luv
UshantaBoth are JDBC drivers, of course. The bridge uses ODBC to accomplish its job, while a 100% Java, type IV JDBC driver does not. One requires that ODBC be installed; the other just needs a JAR in the CLASSPATH. One comes bundled with the JDK; the other is downloaded from the database vendor.
JTA = Java Transaction Architecture
JTS = Java Transaction Service -
Newbie: Problem with jdbc-odbc and MS SQL server 2005
I'm on win vistax64 with SQLSERVER 2005 and I have set up the odbc source as system dsn using the SQL Native Client driver with SQL authentication and the connectivity test in the end succeeds.
I'm trying to make a simple web app that will connect to the database and perform simple querries. It's a school assignment.
I'm using the jdbc-odbc bridge because it's the simplest way to do it and it's what we were shown in class.
I get the following irritating error:
"Cannot establish a connection to jdbc:odb:sstmdb using sun.jdbc.odbc.JdbcOdbcDriver ([Microsoft][ODBC Driver Manager] Data source name not found and no default driver specifies)".
I'm working with netbeans 5.5.1 and this error is what I get when in the runtime tab I try to connect with the jdbc-odbc. I get a similar error in the logs when I try to run the app on the j2ee server.
This is the java class that establishes the connection.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Connector {
private static final String dbUrl="jdbc:odbc:sstmdb";
private static final String user="kimon";
private static final String password="jackohara";
public static Connection getConnection(){
Connection conn = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection(dbUrl,user,password);
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
return conn;
}It has worked perfectly on my school PC with winXP and MSDE2000.
What am I missing?Ok, help came from an other way where I was inquiring about a different problem:
Connectivity works fine by using User DSN instead of System DSN for the ODBC source. -
someone please help me with this issue. i wonder why i need to put 2 lines of executeUpdate() to successfully insert a new record... thanks in advance for those who helped ;)
peixing.
import java.io.*;
public class Index{
public static void main(String[] args)throws IOException{
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
String userId = "";
System.out.println("Welcome to New World Inc.");
System.out.println("1. Create new user");
int choice = 0;
do{
System.out.print("Please select an option: ");
try{
choice = Integer.parseInt(input.readLine());
catch(NumberFormatException e){
//e.printStackTrace();
choice = 0;
}while(choice<1 || choice>3);
if(choice==1){
Account acc = new Account();
do{
System.out.print("Enter user name: ");
try{
userId = input.readLine();
acc.setUserId(userId);
catch(Exception e){
e.printStackTrace();
}while(userId.equals(""));
import java.sql.*;
public class Account{
DBC dbc;
public Account(){
dbc = new DBC();
dbc.setUp("database");
public void setUserId(String userId){
int status = dbc.updateRequest("INSERT INTO Account VALUES('" + userId + "','','')");
dbc.updateRequest("INSERT INTO Account VALUES('" + userId + "','','')");
//<===== i wonder why i need to write an additional updateRequest then i am able to insert a new record into my database....
//its so weird. and everytime i take away this additional method, i cannot add a new record into my database
import java.sql.*;
public class DBC{
private Connection con;
public void setUp(String dsn){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
catch(Exception e){
System.out.println("Load driver error");
try{
String s = "jdbc:odbc:" + dsn;
con = DriverManager.getConnection(s, "", "");
catch(Exception e){
e.printStackTrace();
public int updateRequest(String dbQuery){
int count=0;
try{
Statement stmt = con.createStatement();
stmt.executeUpdate(dbQuery);
count = 1;
catch(Exception e){
count = -1;
return count;
}DrClap, are you able to give me a solution as to how can i commit the update or close the connection ? however i notice something you might have "mistakened"
its not that i can't create a new record into my database... when i only put a single executeUpdate(), the new record is not created, but when i put 2 lines of executeUpdate() then the new record is reflected in the database...
hope you may give me some code samples to clarify my doubts to this issue.
thanks in advance
peixing. -
Jdbc:odbc driver connection issues
I need to use the jdbc:odbc driver to access a non-oracle db from a jsp. I am sure my dsn is fine as I can use a non JSP java app to connect to the odbc db. I have loaded the sun.jdbc.odbc classes in the schema I am working in as it is not loaded by default in 9.2.0.7 currently I am on a windows system. I have found the following:
public static void doTest()throws Exception{
// load the local Oracle Driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
connLocalOracle = new OracleDriver().defaultConnection();
// load the odbc driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
if I exit at this point the jsp does not through an exception
however if I include the line:
connODBC = DriverManager.getConnection(odbcURL,"XX","XX");
I get the error:
SQL> execute do_jdbc_odbc_test;
BEGIN do_jdbc_odbc_test; END;
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
java.lang.UnsatisfiedLinkError: sun.jdbc.odbc.JdbcOdbc.allocConnect
ORA-06512: at "TU1.DO_JDBC_ODBC_TEST", line 0
ORA-06512: at line 1
So I am assuming I am loading the driver but the driver is not talking to the odbc configuration in windows.
What permissions would I need to give to the user to allow this connection to occur?
How can I find out if this is indeed the case?
If not how can I make this connection happen using ODBC?If by jsp you mean Java Stored Procedure, the hybrid JDbc-ODBC stack won't work. You can connect to non-Oracle RDBMS from within Java in the database by using a pure Java JDBC driver of the target RDBM. Fwiw, a complete example connecting to SQl Server from with JavaDB is described in my upcoming book. (See http://db360.blogspot.com/)
Kuassi -
Remote Database connection throught JDBC-ODBC
Hi everybody
I've developed an application which connects to a MS Access database throught the JDBC-ODBC bridge; if the database is on my local machine I've no problem at all, but I now need to connect to a database on a remote PC. I've set the DSN entry for the database on the remote computer and try to connect using something like:
String db_name="jdbc:odbc:remote_pc_name\\\\DSN_db_name";
Properties db_prop=new Properties();
db_prop.setProperty("user","username");
db_prop.setProperty("password","user_password");
Connection dbconn=DriverManager.getConnection(db_name,db_prop);
but the ODBC driver gives me the message
"[Microsoft][ODBC Driver Manager] DSN not found and driver not specified.
I've tried other possible "connection strings" but I always get the same message.
The software works properly if I connect to the local DB with:
String db_name="jdbc:odbc:DSN_db_name";
Any idea how to connect to a remote DB through ODBC?
ThanksNo need for a separate thread really is there? its still relevant to the original.
import java.awt.*;
import java.sql.*;
public class JDBC1 extends Frame {
private static final String DB = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=\\\\http:\\\\www.cs.stir.ac.uk\\~dcl\\databasename.mdb";
public static void main(String[] arguments) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
System.out.println("Driver registered!");
Connection conn = DriverManager.getConnection(DB, "", "");
System.out.println("Connected!");
Statement st = conn.createStatement();
System.out.println("Statement created!");
ResultSet rec = st.executeQuery("SELECT * FROM people");
System.out.println("Queried!");
while( rec.next() ) {
System.out.println( rec.getString(2) );
st.close(); //close the statement
conn.close(); //close the connection
catch( SQLException s ) {
System.out.println("SQL Error: "+ s.toString() + " " + s.getErrorCode() );
s.printStackTrace();
catch( Exception e ) {
System.out.println("Error: "+ e.toString() + e.getMessage() );
} -
JDBC-ODBC bridge for MSSQL database
Hi,
I have SAP 2 MSSQL synchronous scenario and I need to select data from MS SQL 2005 database located on the remote system via XI 3.0. The database provides only ODBC access. I am using JDBC receiver and I would like to use sun.jdbc.odbc.JdbcOdbcDriver as a driver. I searched this forum, but the most of threads describe, how to connect to MS Access database, which is not my case. I used XI JDBC/FTP connection Test and XML Validation Application described in SAP Note 1085539 to test it. I used the following settings:
Driver Class (fully qualified) sun.jdbc.odbc.JdbcOdbcDriver
JDBC URL jdbc:odbc:Driver://<host IP>;databaseName=<name>
User Name my username
Password my password
I got the following error:
Exception Occurred : [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Exception Stack Trace : java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
My questions are: Is it possible to use sun.jdbc.odbc.JdbcOdbcDriver in this scenario? If so, what should I put as JDBC URL? Do I need to create DSN on the XI system? (it is a Windows NT based machine).
Thanks a lot for your answers.Have you already deployed the drivers (msbase.jar, mssqlserver.jar, msutil.jar) ??
If so,
The JDBC drivers should be:
com.microsoft.jdbc.sqlserver.SQLServerDriver
And the connection should be:
jdbc:microsoft:sqlserver://hostname:1433;DatabaseName=name
else
For the drivers:
http://developers.sun.com/product/jdbc/drivers -
Use of sun.jdbc.odbc.JdbcOdbcDriver
Hi, I'm starting to work with Java and I'm trying to connect to a SQL Server 2000 database using "sun.jdbc.odbc.JdbcOdbcDriver" driver but when I try to make the connection I get this error:
"java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Cannot get connection"
Here is the my code:
final static private String _driver = "sun.jdbc.odbc.JdbcOdbcDriver";
final static private String _url = "jdbc:odbc:<databasename>";
Class.forName(_driver); // Load Driver
c = DriverManager.getConnection(_url, "<user>", "<passwd>");
} catch (java.lang.ClassNotFoundException e){
System.out.println(e.toString());
System.out.println("Cannot find driver class");
System.exit(1);
} catch (java.sql.SQLException e) {
System.out.println(e.toString());
System.out.println("Cannot get connection");
System.exit(1);
Someone can help me with this ?? I'm stuck !!
Thanks !!Hi, I'm starting to work with Java and I'm trying to
connect to a SQL Server 2000 database using
"sun.jdbc.odbc.JdbcOdbcDriver" driver but when I try
to make the connection I get this error:
"java.sql.SQLException: [Microsoft][ODBC Driver
Manager] Data source name not found and no default
driver specified
Cannot get connection"
Here is the my code:
final static private String _driver =
"sun.jdbc.odbc.JdbcOdbcDriver";
final static private String _url =
"jdbc:odbc:<databasename>"; the DSN that you set up for connecting to your database. is it called <databasename>? somehow i doubt it. -
Compile error when connecting to JDBC:ODBC
Hi
I am not used to java so probably this is an enivorment problem, but I cannot fix, please help!
FOLLOWING CODE
import java.sql.*;
public class DBtest {
public static void main (String args[]) {
String jdbcDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String protocolHeader = "jdbc:odbc:";
String dbName = "myodbc3-test";
String user = "";
String password = "";
Class.forName(jdbcDriver);
Connection cn =
DriverManager.getConnection(protocolHeader+dbName, user, password);
GENERATES FOLLOWING COMPILING ERROR
cd c:/Javakod/NewFolder/
javac -classpath C:\Javakod\ DBtest.java
DBtest.java:17: incompatible types
found : java.sql.Connection
required: NewFolder.Connection
DriverManager.getConnection(protocolHeader+dbName, user, password);
^
1 error
What is wrong? I am using a Win2000.This code compiles and runs fine on my Windows 2000 machine running JDK 1.4.1:
import java.sql.*;
public class AnotherConnectionTester
public static void main(String [] args)
String jdbcDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String protocolHeader = "jdbc:odbc:";
String dbName = "myodbc3-test";
String user = "";
String password = "";
try
Class.forName(jdbcDriver);
Connection cn = DriverManager.getConnection(protocolHeader+dbName, user, password);
DatabaseMetaData meta = cn.getMetaData();
System.out.println("product name: " + meta.getDatabaseProductName());
catch (Exception e)
e.printStackTrace(System.err);
}I set up an ODBC DSN myodbc3-test to connect to an Access database. It was no problem. I guess that doesn't explain why your post didn't work. I changed the name of the class and added that meta data output so I could make sure that it connected. - MOD -
JDBC-ODBC BRIDGE "No Suitable Driver"
I am trying to link the JAVA (VJ++) to MS ACCESS 2000. I am always getting the error: "No Suitable Driver"
I am sure I that I have set up the SYSTEM DSN and installed jdk1.2.2 correctly. I just can't understand why it insists on not working!!??
I have tryed everything I know, but I still cant get this problem sorted and I'm about to give up. Does the driver even work when trying to establish this kind of link???!!!
CODE:
public class AuditConnect
private Connection Aconn;
private String strUrl = "jdbc:odbc:CSDMATlink";
private String user = "tiger";
private String password = "tiger";
private String Err;
public AuditConnect()
try
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
catch(ClassNotFoundException ex)
Err = ex.getMessage();
Aconn = DriverManager.getConnection(strUrl, user, password);
catch(SQLException SQLErr)
Err = SQLErr.getMessage();
Help me please, I'm desperate!!!A new version of the JDK was not necessary to fix the problem. In any event let's start with configuring your box correctly. The CLASSPATH environment variable is not necessary when using the core JDK classes (of which the JDBC-ODBC bridge classes are a part of). The CLASSPATH environment variable should only be used if you have third party class libraries you wish to add. I'm assuming that's not the case so I would recommend not coding the CLASSPATH variable. However if you have it already coded make sure to add the current directory (as denoted by a dot). For example:
SET CLASSPATH=.;c:\JDK1.4.1_03\jre\lib\rt.jar
Although the CLASSPATH is not necessary the PATH environment variable is crucial. You need to add the JDK's BIN directory to your current PATH statement. For example:
SET PATH=%PATH%;c:\JDK1.4.1_03\bin
The above should resolve the No suitable driver problem you've been encountering. Since JDK 1.2.x the JDK's CLASSPATH is resolved via the PATH setting.
Now as per my previous post you need to make sure that you really do have a well formed JDBC URL as that can also cause the No suitable driver problem.
I'm not familiar with Win98 so I don't know if you update the environment variables via the AUTOEXEC.BAT file or if you use the Control Panel ala WinNT. Check your documentation to ensure you're updating correctly. Good luck. -
Java Web Analyzer security hole in SQL Query Spreadsheet using JDBC-ODBC bridge
Hi,<BR><BR>I use Hyperion Analyzer 7.0.1 on Windows 2003 and relation database DB2 v8.2.<BR><BR>I did:<BR>1. log in to Java Web Analyzer<BR>2. button New<BR>3. Select Layout: Custom Report<BR>4. from toolbar pull down to desktop "SQL Spreadsheet" option<BR>5. "Enter SQL Query" window opens, from JDBC Driver drop down window select "JDBC-ODBC Bridge"<BR>6. in "JDBC Connection String" window replace "db1" string with database name<BR>7. leave JDBC Username and JDBC Password empty (this is default)<BR>8. click on "Test Connection" button.<BR>9. "Test Connection" window opens with message "Connection Succeded"!!! So connection to database without password succeeded.<BR>10. in "SQL Query window" write any SQL you wish and Database will execute the SQL.<BR><BR><b>Conclusion: Connecting Analyzer with SQL Spreadsheet option to relation database DB2 is possible without password.</b><BR><BR>Question: Is there any way to prevent users from executing "SQL Spreedsheet" option?<BR><BR>Thanks,<BR>Grofaty
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(dsn,"guest","guest");
OR DriverManager.getConnection(dsn);
System.out.println("Conection's opened");
catch(ClassNotFoundException cnfe)
System.err.println(cnfe);
catch(SQLException sqle)
System.err.println(sqle);
try that code and double check you DSN Name . it's a good practice to greate a system DSN.
i hope that helps.
FEEL FREE TO ASK. WON'T BITE U
ABDUL
Maybe you are looking for
-
How can I find and change text in Hyperlinks?
I have 6000 hyperlinks in my document, I need to change all of the "&" they contain (in the url destination, not in the textflow) to "%26" so I can export to Epub correctly (I'm getting the classic "Export failed" and found out in forums that ampersa
-
Very Frustrated and Wasted Money Please Help Me...... Itunes crashed and all of my libraries would not download, the songs that did came back 3/4 times which caused me to put everything on my new Hard Drive,I am have a bunch of files and libraries fr
-
?: How do you move files to an external hard drive
Hello everyone, I have a 2009 MacBook Pro running Lion 10.7.5 I am starting to run out of internal HD space as my images in Photoshop are very large (over 1 GB ea.) I currently use an external hard drive for Time Machine but would like to use a diffe
-
BPM workspace different port question
Hi, I have a UI project, that is used for BPM human tasks. When I deploy the UI part to the SOA server(default port 8001) then login to BPM workspace and click to my task all works fine(task details page is displayed). But when I deploy the UI part
-
Using filter view in combined request.
Hi, I want to see the filters used in a combined request in a filter view which I am unable to. Can anyone help me with this? Regards, Dev.