Title:
Obrigado pela atenção. Não consigo conectar o banco
de dados. o erro está na linha abaixo no url:
String url = "jdbc:odbc:cadastros";
Connection con = DriverManager.getConnection
(url,"my_user","my_passwd");
erro: NO Suitable Driver.
- Original Message -
From:
Daniel Díaz
To: [EMAIL PROTECTED]
Sent: Sunday, September 03, 2000 12:54
PM
Subject: Re: [java-list] SOS
javaneses
--- luizbarbosa <[EMAIL PROTECTED]> escribió:
>Estou com erro na conexao atraves de um Applet.> >
import java.net.URL;> import java.sql.*;> import
java.awt.*;> import java.applet.*;> > public class Teste
extends Applet> { public void init()>
{ try> { String url =
"c:jdbc:odbc:cadastros";>
>
Class.forName> ("sun.jdbc.odbc.JdbcOdbcDriver");>
> Connection con
=> DriverManager.getConnection (url, "my_user",>
"my_passwd");> > proba url "String url =
"jdbc:odbc:cadastros"; ?nao "String url = "C:
"Daniel
_Do
You Yahoo!?Obtenga su dirección de correo-e gratis @yahoo.comen
http://correo.espanol.yahoo.com
Contents
| Prev
| Next
JDBCTM Guide: Getting
Started
2 - ConnectionThis overview is excerpted from
JDBCTM Database Access from JavaTM: A Tutorial and Annotated Reference,
currently in progress at JavaSoft. This book, both a tutorial and the
definitive reference manual for JDBC, will be published in the spring of 1997
by Addison-Wesley Publishing Company as part of the Java series.
2.1 OverviewA
Connection object represents a connection with a database. A
connection session includes the SQL statements that are executed and the
results that are returned over that connection. A single application can have
one or more connections with a single database, or it can have connections
with many different databases.
2.1.1 Opening a ConnectionThe
standard way to establish a connection with a database is to call the method
DriverManager.getConnection. This method takes a string
containing a URL. The DriverManager class, referred to as the
JDBC management layer, attempts to locate a driver than can connect to the
database represented by that URL. The DriverManager class
maintains a list of registered Driver classes, and when the
method getConnection is called, it checks with each driver in the
list until it finds one that can connect to the database specified in the URL.
The Driver method connect uses this URL to actually
establish the connection.
A user can bypass the JDBC management layer and call
Driver methods directly. This could be useful in the rare case
that two drivers can connect to a database and the user wants to explicitly
select a particular driver. Normally, however, it is much easier to just let
the DriverManager class handle opening a connection.
The following code exemplifies opening a connection to
a database located at the URL "jdbc:odbc:wombat" with a user ID
of "oboy" and "12Java" as the password :
String url = "jdbc:odbc:wombat";
Connection con = DriverManager.getConnection(url, "oboy", "12Java");
2.1.2 URLs in General UseSince URLs
often cause some confusion, we will first give a brief explanation of URLs in
general and then go on to a discussion of JDBC URLs.
A URL (Uniform Resource Locator) gives information for
locating a resource on the Internet. It can be thought of as an address.
The first part of a URL specifies the protocol used to
access information, and it is always followed by a colon. Some common
protocols are "ftp", which specifies "file transfer protocol," and "http,"
which specifies "hypertext transfer protocol." If the protocol is "file," it
indicates that the resource is in a local file system rather than on the
Internet. (Underlining in the examples below is used to indicate the part
being described; it is not part of the URL.)
ftp://javasoft.com/docs/JDK-1_apidocs.zip
http://java.sun.com/products/jdk/CurrentRelease
file:/home/haroldw/docs/books/tutorial/summary.html
The rest of a URL, everything after the first colon,
gives information about where the data source is located. If the protocol is
file, the rest of the URL is the path to a file. For the
protocols ftp and http, the rest of the URL
identifies the host and may optionally give a path to a more specific site.
For example, below is the URL for the JavaSoft home page. This URL identifies
only the host:
http://java.sun.com
By navigating from this home page, one can go to
many other pages, one of which is the JDBC home page. The URL for the JDBC
home page is more specific and looks like this:
http://java.sun.com/products/jdbc
2.1.3 JDBC URLs A JDBC URL