Link to home
Start Free TrialLog in
Avatar of ws1999
ws1999

asked on

about applet access database

hello experts,

     ResultSet rs=null;
          try {
               Class.forName("com.ms.jdbc.odbc.JdbcOdbcDriver");
               Connection con=DriverManager.getConnection("jdbc:odbc:MyODBC","sa","");
               Statement sm=con.createStatement();
               rs=sm.executeQuery(sql);
          }

it works well in my computer, but when i upload it to internet,(my Web server has Database and ODBC), i found it still access the ODBC resource(the MyODBC) of my computer,so it is terrible that every customer using the applet must configure a ODBC in there own computer,

that is not i want to see.

Is there any method to solve this by coding or by configuration on the server?

worried ws1999

Avatar of superschlonz
superschlonz

You need to use a full java driver for mysql.
I think you find links at www.mysql.com
ASKER CERTIFIED SOLUTION
Avatar of ibrnadic
ibrnadic

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mick Barry
I think you need to include the hostname of the db in your connection string. Try a connection string like:

"jdbc:odbc://<host>/MyODBC"

where <host> is where the host where the db resides.
Avatar of ws1999

ASKER

hello objects,

can the IP address replace the hostname?

ws1999
Avatar of ws1999

ASKER

hello object,

what kind of configuration should be done on the server side,now i am connecting with my ISP

JDK i think should be needed ,anything else?

ws1999
Should just need the DSN setup.
Nothing else should be necessary (unless your JDBC driver requires any server side component).
Avatar of ws1999

ASKER

DSN???

what's that?

ws1999
Avatar of ws1999

ASKER

DSN,DSN i know,sorry object,

should the JDK Classpath needed on server??

ws1999
Data Source Name.
It used by ODBC on the server.
1. Create a ODBC datasource on your server, you will have to give it a name for example you called it MyODBC
2. Set the CLASSPATH on your server to have the jar file that contains your JDBC drivers i.e. the zip or jar file that has the com.ms.jdbc.odbc.JdbcOdbcDriver.class file.
3. Connection using the url: "jdbc:odbc://<host>/MyODBC"
The code would look something like:
ResultSet rs=null;
         try {
              Class.forName("com.ms.jdbc.odbc.JdbcOdbcDriver");
              Connection con=DriverManager.getConnection("jdbc:odbc://myDBserver/MyODBC","sa","");
              Statement sm=con.createStatement();
              rs=sm.executeQuery(sql);
         }

Basically that's just a repeat of the comments made by objects earlier points should go to objects.
Avatar of ws1999

ASKER

hello black

the DBServer can be ip address?

ws1999
yes
Avatar of ws1999

ASKER

still cannot work:

     ResultSet rs=null;
          try {
               Class.forName("com.ms.jdbc.odbc.JdbcOdbcDriver");
               Connection con=DriverManager.getConnection("jdbc:odbc://202.103.190.14/myODBC","sa","");
               Statement sm=con.createStatement();
               rs=sm.executeQuery(sql);
          }
          catch(SQLException ex){
    }
          catch(java.lang.Exception ex){
    }
          return rs;
     }

on the server yes, it can work, but when running from client, it cannot.unless configer the client's DSN,it's really terrible, i have tested many many times.

Avatar of ws1999

ASKER

i have draw conclusion that use jdbc-odbc  you must configure the DSN on Client side.

How can i avoid JDBC-ODBC, is there any native JDBC which can access SQL Server directly?


ws1999
In addition to a Type 4 driver, a type 3 driver will also meet your needs.

For SQL Server have a look at:
www.freetds.org
www.j-netdirect.com
www.merant.com



This question is LOCKED with a Proposed Answer.  If it helps you, great, accept it and grade it to close.  If not, reject it and comment as to why or what else is needed.

Few additional experts will join this collaboration effort, once a question has been locked.  Just want to confirm this to you.  If more than one expert helps you, you can always split points or award additional help in a new question, within the same topic area.  If you need help from us, post a zero point question here, and include the link:

EXPERT INPUT ON OUTCOME ALWAYS WELCOME.

https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

Moondancer
Community Support Moderator @ Experts Exchange
ws1999:

You have many open questions to which you must return:

https://www.experts-exchange.com/jsp/qShow.jsp?ta=msaccess&qid=20264790
https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20256743
https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20250343
https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20249986
https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20187323
https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20184015
https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20181707
https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20180448
https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20169990
https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=11401958
https://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20230693
https://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20194172
https://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20187856
https://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20187852
https://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20187466
https://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20182301
https://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20182182
https://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20181487
https://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20181301
https://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20180787
https://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20180436
https://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20172201
https://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20153303

To assist you in your cleanup, I'm providing the following guidelines:

1.  Stay active in your questions and provide feedback whenever possible. Likewise, when feedback has not been provided by the experts, commenting again makes them receive an email notification, and they may provide you with further information. Experts have no other method of searching for questions in which they have commented, except manually.

2.  Award points by hitting the Accept Comment As Answer button located above and to the left of that expert's comment.

3.  When grading, be sure to read:
https://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp#3
to ensure that you understand the grading system here at EE. If you grade less than an A, you must explain why.

4.  Questions that were not helpful to you should be PAQ'd (stored in the database for their valuable content?even if not valuable to you) or deleted. To PAQ or delete a question, you must first post your intent in that question to make the experts aware. Then, if no experts object after three full days, you can post a zero-point question at community support to request deletion or PAQ. Please include the link(s) to the question(s).
CS:  https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
At that point, a moderator can refund your points and PAQ or delete the question for you. The delete button does not work.

5.  If you fail to respond to this cleanup request, I must report you to the Community Support Administrator for further action.

Our intent is to get the questions cleaned up, and not to embarrass or shame anyone. If you have any questions or need further assistance at all, feel free to ask me in this question or post a zero-point question at CS. We are very happy to help you in this task!


thanks!
amp
community support moderator

2/8
ws1999, I see that you have logged in.  It is my sincerest hope that you have returned to take care of these questions.  A Moderator has notified you of the problem, and taken the time to list them all for you to access them quickly.

Please start on or finish them today, and save me the troulble of having to write you.  This is a plea from me to do the right thing, and finalize these as soon as possible.  I wish not to take this any further, but if need be, I will.

Best regards,
ComTech
CS Admin @ EE
Avatar of ws1999

ASKER

thanks