Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > DatabaseMetaData.getTables help
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 3rd November 14:05
paul
External User
 
Posts: 1
Default DatabaseMetaData.getTables help



I get a NullPointerException when I run the following:

import java.sql.*;

public class SimpleDB {
private static final String
DRIVER_CLASS = "com.mysql.jdbc.Driver" ;
private static final String
DB_URL = "jdbc:mysql://localhost/imsample" ;

public SimpleDB() {
Connection con = null ;
DatabaseMetaData dmd = null;
try {
Class.forName(DRIVER_CLASS);
con = DriverManager.getConnection
(DB_URL,"root","");
ResultSet rs = dmd.getTableTypes();

} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (con != null) {con.close();}
} catch (SQLException ignore) }
}
}

public static void main(String[] args){
new SimpleDB();
}
}

I actually was trying run the getTables method so that I could
see if a table existed before creating it. (If there is a better
way to do this, I'm all ears).

I figured that if could get getTableTypes to work, then
getTables should work as well.

Thanks

Paul
  Reply With Quote


 


2 3rd November 14:06
lori m olson [teamb]
External User
 
Posts: 1
Default DatabaseMetaData.getTables help



Are you missing some code here? At what point do you actually
initialize "dmd"?

--

Regards,

Lori Olson [TeamB]

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html
  Reply With Quote
3 3rd November 14:06
john moore
External User
 
Posts: 1
Default DatabaseMetaData.getTables help


Yeah, what is missing is

dmd = con.getMetaData();

(Probably was copying out of the example in the help.. missed a
line..<G>)

i.e. .....

Class.forName( DRIVER );
con = DriverManager.getConnection( URL + "Tx.jds", "Chuck", "" );
stmt = con.createStatement();
dmd = con.getMetaData();
rs = dmd.getTables( null, null, "Accounts", null );


--
=============================================
TeamB are volunteer helpers. Please DO NOT REPLY VIA EMAIL!
Post all questions and replies to this newsgroup ONLY
For papers on DataExpress, Applets, JSP, and Web Development go to:
http://www.microps.com/mps/paperFAQ.html
================================================== ==
  Reply With Quote


 


4 12th November 03:10
kelvinq
External User
 
Posts: 1
Default JB2005 /Windows2000: jar does NOT run with mySQL


BE WARNED JBuilder2005 on windows2000 does NOT work with latest mysql!!
using windows2k/JB2005 I can connect to mysql
using mysql-connector-java-3.0.14-bin.jar
in the IDE
but *CANNOT* run standalone jar.
using 3.0.14-production-bin.jar

So either: JBuilder2005 doesnt make a functioning jar
OR JBuilder2005 doesnt work with 3.0.14 in windows2000

(also tried with 3.1.10 - so latest version does NOT work)

History:
I can run a standalone jar from Windows98
on a Windows98 machine
with mysql-connector-java-3.0.8-stable-bin.jar
INSIDE myprog.jar
[mysql \s gives Server Version 3.23.55]

the same jar does NOT run on windows 2000 BE WARNED!!!
  Reply With Quote
5 12th November 03:10
kelvinq
External User
 
Posts: 1
Default JB2005 /Windows2000: jar does NOT run with mySQL


on the Win2K box, mysql \s gives:
mysql ver 14.7 Distr 4.1.9, for Win95/98
... server version 4.1.9-nt

- Note it does NOT say Win2000,
maybe I need a new mySQL....

BUT the fact remains: if jou have many users,
*many* of them may have problems

Sadly: java here is *NOT* write once, run anyware,
but: a matrix of Borland version/mySql version/Operating systems
with some combinations working, some not.

NOTE: this assertion remains true, even if I manage to get some combination working on my win2K box; my users MAY or MAY NOT have a working combination.

mySQL forums say "ask Borland, we dont use JBuilder around here"
  Reply With Quote
6 12th November 03:10
lori m olson [teamb]
External User
 
Posts: 1
Default JB2005 /Windows2000: jar does NOT run with mySQL


Is there a question about JBuilder here somewhere? From this little
rant, all I can see is that you answered your own question... You need
an updated version of MySQL. This has nothing to do with JBuilder.

--

Regards,

Lori Olson [TeamB]

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html
  Reply With Quote
7 12th November 03:10
kelvinq
External User
 
Posts: 1
Default JB2005 /Windows2000: jar does NOT run with mySQL


So we have the perfect double bounce. .....

mySQL says ask Borland, Borland say ask mySQL

- the question is: given that mySQL works in JB2005 IDE, how do I
make it work for the jar?

Never mind, I have discovered Firebird database (Interbase reborn?) which JB2005 runs in a jar OK.
  Reply With Quote
8 12th November 03:10
lori m olson [teamb]
External User
 
Posts: 1
Default JB2005 /Windows2000: jar does NOT run with mySQL


But you didn't ask Borland anything. You posted in this newsgroup,
which is a *peer-supported* group.

http://www.teamb.com

And I didn't say "ask MySQL". I asked for clarification. You made two
postings in which you did not ASK anything. You posted a rant, in which
the closest thing to a question was this statement -

================================
- Note it does NOT say Win2000,
maybe I need a new mySQL....
================================

I agreed. If you are running MySQL on Windows 2000, and that version of
MySQL does not support Windows 2000, then THAT is the place to start
looking for solutions to your problems.

Now, if you have other questions to be answered, then go ahead and ask
them. And please try to include all relevant details, like how your
project is set up, what versions of everything you are using, and what
*exactly* is the error message you are getting.

--

Regards,

Lori Olson [TeamB]

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html
  Reply With Quote
Reply


Thread Tools
Display Modes




666