Java Database Program

Java Database Program

Post by Luca » Wed, 02 Oct 2002 23:40:36



Hello, does anyone knows how to run the following program? I try to
pass arguments into it but I get the following error,
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:532)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at data.main(Data.java:30)

The program is as below:

import java.net.URL;
import java.sql.*;

class data {
public static void main(String argv[]) {
if (argv.length == 0) {
System.err.println("Usage");
System.err.println("");
System.err.println("java jdbc_connect URL");
System.exit(1);

Quote:}

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

String url = argv[0];

String user, pwd;
if (argv.length > 1) {
user = argv[1];

Quote:} else {
user = "";
}

if (argv.length > 2) {
pwd = argv[2];

Quote:} else {
pwd = "";
}

Connection con = DriverManager.getConnection(url, user, pwd);
con.close();
System.out.println("Connection successfully.");
Quote:}

catch( Exception e ) {
System.out.println(e.getMessage());
e.printStackTrace();

Quote:}
}
}

Thank you in advance.

Regards,
Lucas

 
 
 

Java Database Program

Post by Linda Radeck » Thu, 03 Oct 2002 00:11:10



> Hello, does anyone knows how to run the following program? I try to
> pass arguments into it but I get the following error,
> java.sql.SQLException: No suitable driver
> at java.sql.DriverManager.getConnection(DriverManager.java:532)
> at java.sql.DriverManager.getConnection(DriverManager.java:171)
> at data.main(Data.java:30)

> The program is as below:

[Your program]

What have you passed in as argument? Anyway, you'll need
to pass the DSN, e.g like jdbc:odbc:<datasourceYouReferTo>
when you run it.  Hope this helps

Linda
--

 /


 
 
 

Java Database Program

Post by Luca » Thu, 03 Oct 2002 23:46:00




> > Hello, does anyone knows how to run the following program? I try to
> > pass arguments into it but I get the following error,
> > java.sql.SQLException: No suitable driver
> > at java.sql.DriverManager.getConnection(DriverManager.java:532)
> > at java.sql.DriverManager.getConnection(DriverManager.java:171)
> > at data.main(Data.java:30)

> > The program is as below:

> [Your program]

> What have you passed in as argument? Anyway, you'll need
> to pass the DSN, e.g like jdbc:odbc:<datasourceYouReferTo>
> when you run it.  Hope this helps

> Linda

Hi Linda,
Thank you very much for your help. It works.

Regards,
Lucas

 
 
 

1. ANN: Java Database Programming on hackerz netcast with Brian Jepson

Brian Jepson, author "Java Database Programming" will be the guest of
hackerz on the Pseudo Online Network this Friday.

Topic:  Java Database Programming (including JDBC)

Guests: Brian, and you

What:
hackerz, a real-audio + chat netcast for developers and their ilk

When:  
Friday June 13, 7:00pm est

Where:  
http://www.xmatrix.com/hackerz

How:    

Audio: Real-Audio 3.0, download it at http://www.real.com

Chat: using a standard irc client connected to irc.pseudo.com 6667
or using pseudo's java webchat, http://www.pseudo.com/chat
channel is: #techtalk.hackerz

Email:  

Send advance questions and topic suggestions to

from the chat room during the event.

----------------------------------------------------
For more information or to listen to previous shows,
visit http://www.xmatrix.com/hackerz

Past shows include:

- MFC, with "MFC Internals"'s Scot Wingo
- Internet Security with NCSA's Ira Winkler,
- Visual C++, with Microsoft's Steve Ross
- Java, with Javaworld's Bret  Sommers
- VRML, with Gavin Bell

and MORE...

----------------------------------------------------
hackerz is produced by the Pseudo Online Netwrok,
http://www.pseudo.com

2. Kickoff Access queries from VB?

3. i am writing my masters thesis on java database programming

4. pgsql/ oc/FAQ_QNX4 rc/backend/Makefile rc/back ...

5. Request of most recommended books on Java Database Programming

6. Cursor life after a Critical Error in SQL 2000

7. ---JAVA-----JAVA-----JAVA-----JAVA-----JAVA-----JAVA-----JAVA-----JAVA---

8. Lastname,firstname,plan

9. CGI programming using JAVA (comparing JAVA & Perl)

10. Connecting a java program/applet to Informix database

11. help for create a database in java program

12. JDBC FAQ - Programming Databases with Java

13. Program for OOPSLA Workshop on Java and Databases