Driver For JDBC With Ms SQL Server 7.0

I currently doing a simple Java applet that allow users to enter the data.  The applet will using Microsoft SQL Server 7.0 as database.  I facing the error message "not suitable driver"  when execute the program.  Can anyone tell what driver I need to use and where I can download it.  Below is the source code.  Hope that somebody will help me solve the problem adn reply me thru huangaun@yahoo.com.

import java.awt.*;
import sun.applet.AppletSecurity.*;
import sun.applet.*;
import java.applet.Applet.*;
import java.awt.event.*;
import java.applet.*;
import java.sql.*;
import java.io.*;
import sun.jdbc.odbc.*;
import java.net.URL;
import java.util.*;

class Person{

      String FName, LName, EMail;
      long id;

      public void Print(){
            System.out.println(FName + "\t" + LName + "\t" + EMail);
      }

Person(long l, String fn, String ln, String em){
            FName = fn;
            LName = ln;
            EMail = em;
            id = l;
      }
}

public class PeopleMaker extends Applet implements ActionListener{

      Button btnAdd;
      TextField txtFName,txtLName,  
        txtEMail;
      Label lblFName, lblLName,
        lblEMail;
      
      public void init(){
      setLayout(new GridLayout  
        (4,2,5,5));

      lblFName = new Label("First
        Name:");
      add(lblFName);
      txtFName = new TextField(30);
      add(txtFName);

      lblLName = new Label
        ("Last Name:");

      add(lblLName);
      txtLName = new TextField(30);
      add(txtLName);

      lblEMail = new Label("EMail
        Address:");
      add(lblEMail);
      txtEMail = new TextField(30);
      add(txtEMail);

      btnAdd = new Button("Add
        Person");
      btnAdd.addActionListener(this);
      add(btnAdd);
      }

      public void actionPerformed
        (ActionEvent e){
      if (e.getSource() == btnAdd){
                  String SQLQuery;
                  SQLQuery
         = "INSERT INTO SPR (FName,
         LName, EMail) VALUES ('" +
                               txtFName.getText() + "', '" +
                               txtLName.getText() + "', '" +
                               txtEMail.getText() + "');";
      

            try{
                  

                        Class.forName  
       ("sun.jdbc.odbc.JdbcOdbcDriver");
                        Connection con =
        DriverManager.getConnection
        ("jdbc:odbc:SRP","","");
                        Statement stmt =
        con.createStatement();
      int recordcount =
        stmt.executeUpdate(SQLQuery);
            
                        stmt.close();
                        con.close();
                  }
                  catch (Exception x) {
                        System.out.println(x.getMessage
       ());
                  x.printStackTrace();
                  }

      txtFName.setText
        ("");
      txtLName.setText("");
      txtEMail.setText("");
      }      
      }
}
                  
HuangAunAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

heyhey_Commented:
JdbcOdbc bridge is not a good choice for applets (you have to configure ODBC data source name on the client machine)

get some real Jdbc driver
check
http://www.javasoft.com/products/jdbc/drivers.html
0
HuangAunAuthor Commented:
Thanks,  Vladi21
U mentioned that JdbcOdbc bridge is not a good choice for applets .  So what ur opinion for the better driver in MS SQL Server.  Then what U mean with ODBC data source configuration in client machine.  I have take a look the at side.  But I cant get enough information from there.  I also confused
with what the suitable driver. Can U explain more details.  Thanks.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

heyhey_Commented:
JdbcOdbc bridge
1. uses native code (ordinary applets are not allowed to use native code)
2. works only on Windows machines (?)
3. needs configuration on the client machine (Control Panel / ODBC / Configure new ODBS datasource)

so it is not suitable for applets.
I haven't used MS SQL and I don't have my bookmarks, so I can't recomend you Jdbc driver, but take a look at the URL, get the drivers and try them (they probably have some gfood examples)
0
vladi21Commented:
also look:

Java Database Connectivity is a standard SQL database access interface, providing uniform access to a wide range of relational databases. It also provides a common base on which higher level tools and interfaces can be built. This comes with an "ODBC Bridge" (except on Mac 68K). The Bridge is a library which implements JDBC in terms of the ODBC standard C API.
http://java.sun.com/products/jdk/1.1/docs/guide/jdbc/index.html
http://java.sun.com/products/jdbc/index.html
http://java.sun.com/docs/books/jdbc/intro.html
http://java.sun.com/products/jdbc/faq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JDBC
http://java.sun.com/javareel/isv/Simba/products/jdbcfaq.html

Writing Advanced Applications Chapter 4: JDBC Technology
http://developer.java.sun.com/developer/onlineTraining/Programming/JDCBook/jdbc.html

JDBC basics by Thornton Rose (example programs by April Rose)
http://www.gamelan.com/journal/techworkshop/060899_jdbc.html

JDBC and Database Programming in Java (good quick overview with images :)
http://www.purpletech.com/java/courses/jdbc/body.html

Silicaon Valley Java SIG JDBC Talk Page
http://www.hooked.net/~gturner/JDBCTalk.html

Java how-to DB section!
http://tactika.com/realhome/javaht/java-d1.html
http://codeguru.developer.com/java/Miscellaneous/Database/index.shtml
http://java.sun.com/products/jdk/1.3/ja/docs/ja/guide/jdbc/getstart/SimpleSelect.doc.html


articles from Oracle:
http://technet.oracle.com/tech/java/sqlj_jdbc/index.htm

articles from javaworld:
http://www.javaworld.com/javaworld/common/jw-ti-jdbc.html

JDBC 2.0 New Features
http://java.sun.com/products/jdk/1.3/docs/guide/jdbc/getstart/appendixA.html#1006294
http://java.sun.com/docs/books/tutorial/jdbc/jdbc2dot0/index.html

MS bridge
http://www.microsoft.com/Java/sdk/relnotes/JDBCrel.htm
http://msdn.microsoft.com/downloads/samples/Internet/author/datasrc/jdbcapplet/default.asp
0
HuangAunAuthor Commented:
Hi! : Heyhey
Thanks for U reply answer.
U said that get the real JDBC driver.
ut I didnt know whcih driver I need to install and where I can download it.
Please guide me on it.

Thanks.

0
HuangAunAuthor Commented:
Hi! Vladi21
Very thanks for ur reply.  I still confused with th edriver I need to install for me to access Ms SQL Server 7.0.  What the driver manager I should type for bellow connection :-

Class.forName         ("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con =
        DriverManager.getConnection
        ("jdbc:odbc:SRP","","");

thanks.
0
Ravindra76Commented:


You have to use type3 and type4 drivers for applets accessing database drivers.

not jdbcodbc bridge.

 From: Jod
 Date: Thursday, November 18 1999 - 02:40AM CST  
 
Look here for details on oracle (as an example)

http://wpi.wpi.edu/java.815/a64685/getsta1.htm#1002361 

For example:

JDBC Thin Driver

The Oracle JDBC Thin driver is a 100% Pure Java implementation that complies with the JDBC 1.22
 standard. The JDBC Thin driver uses Java Sockets to connect directly to the Oracle Server and
is typically used for Java applets in either a two-tier or three-tier configuration, though
 it can also be used for Java applications. The JDBC Thin driver provides its own
implementation of a TCP/IP version of Oracle's Net8. Because it is written entirely in Java,
 this driver is platform-independent. When the JDBC Thin driver is used with an applet,
 the client browser must have the capability to support Java sockets.

The JDBC Thin driver does not require Oracle software on the client side;
 it can be downloaded into a browser simultaneously with the Java applet being run.
 From the client (usually a browser), you select a URL from an HTML page that contains a
Java applet tag. The web server downloads the Java applet and the JDBC Thin driver to the
 client. The JDBC Thin driver then establishes a direct connection to the database server
using Java Sockets.

The JDBC Thin driver connects to any Oracle database of version 7.2.3 and higher.
 The JDBC Thin driver allows a direct connection to the database by emulating Net8 and
 TTC (the wire protocol used by OCI) on top of Java sockets. The driver supports
only TCP/IP protocol and requires a TNS listener to be listening on TCP/IP sockets
from the database server.

There are four types of driver that Java can use to connect to a database directly:

1.The JDBC-ODBC bridge provides JDBC access via most ODBC drivers.

2.A native-API partly-Java driver converts JDBC calls into calls on the client
  API for Oracle, Sybase, Informix, DB2, or other databases.

3.A net-protocol pure-Java driver translates JDBC calls into a database-independent
   net protocol which is then translated to a proprietary database vendor network protocol
  by a server.

4.A native-protocol pure-Java driver converts JDBC calls into a proprietary database vendor
 network protocol.


A Type 3 driver can connect directly from the client to the Server and a two-tier
 type 4 driver could also do this if it connects directly across the network to the database
 server because neither of these types of driver have any dependence on software installed
 on the client.

Other types of driver require the applet to be signed in order to access local propritary
 code to get to the database.


None of these specifically require RMI, but you will need to check what support
 fetures your server has for JDBC connections.


There is lots of info here:

http://java.sun.com/products/jdbc 

and amongst others, some overviews here:

http://java.sun.com/docs/books/jdbc/intro.html 

and

http://www5conf.inria.fr/fich_html/papers/P23/Overview.html 
 
 Type 3 and type 4 expensive drivers.

Two solutions for you.

1. Uisng type 3 and type 4 drivers.

2. Writing database login in java servlets and calling servlets from applet through URLConnection class.
 
Best of luck
0
muraliramCommented:
As so many of them asnwered JdbcOdbc driver is not a good choice for applets.
This will work fine with intranets
You have to use a Type-3 JDBC driver.
You can go to www.idssoftware.com and download the evaluation copy of ids  driver. This is a type-3 driver which is able to connect to MS SQl server or virtually any Database. Then you can connect using that.


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ravindra76Commented:
http://java.sun.com/products/jdbc/faq.html


How can I use the JDBC API to access a desktop database like Microsoft Access over the network?

Most desktop databases currently require a JDBC solution that uses ODBC underneath.
This is because the vendors of these database products haven't implemented all-Java JDBC drivers.


The best approach is to use a commercial JDBC driver that supports ODBC and the database you
want to use. See the JDBC drivers page for a list of available JDBC drivers.

The JDBC-ODBC bridge from Sun's Java Software does not provide network access to desktop databases
by itself. The JDBC-ODBC bridge loads ODBC as a local DLL, and typical ODBC drivers for desktop databases
like Access aren't networked. The JDBC-ODBC bridge can be used together with the RMI-JDBC bridge ,
however, to access a desktop database like Access over the net. This RMI-JDBC-ODBC solution is free.
http://dyade.inrialpes.fr/mediation/download/ 

also look
http://java.sun.com/products/jdk/1.1/docs/guide/jdbc/index.html 
http://java.sun.com/docs/books/jdbc/intro.html 

Java how-to DB section!
http://tactika.com/realhome/javaht/java-d1.html 
http://codeguru.developer.com/java/Miscellaneous/Database/index.shtml 

0
Ravindra76Commented:

www.idssoftware.com 

It's alreday given vladi21 comments
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.