AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Possible JDBC installation or usage problem in OS X

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases
View previous topic :: View next topic  
Author Message
barry_normal
Guest





PostPosted: Wed Dec 20, 2006 4:03 pm    Post subject: Possible JDBC installation or usage problem in OS X Reply with quote



Hello there,

I'm having a terrible time trying to use the JDBC in os x.

What I want to do is use a program written in java and executed on my
mac to connect to a database on my website and INSERT a huge amount of
data. I have to do this as the upload limit on the web hosting is 2MB
and I've got a GB of data...

So, I've downloaded and extracted the jdbc mysql driver:
mysql-connector-java-3.1.14

Then I've opened my etc/profile file and added the location to the
classpath like this:

PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/mysql-connector-java-3.1.14/mysql-connector-java-3.1.14-bin.jar"
export PATH - This might be the problem but I couldn't find an
explicit example of how to do this...

Then I connect to the DB like this:

....
Class.forName("com.mysql.jdbc.Driver");
} catch (Exception ex) {
// handle the error
}

String conStr = "jdbc:mysql://http://mywebsite.net/myDatabase";

try {
Connection conn = DriverManager.getConnection(conStr, "user", "pass");
System.out.println("connected");
}
....


The result is always this:

SQLException: No suitable driver
SQLState: 08001
VendorError: 0

I'm a long way from being an expert so this is totally baffling me. Any
help would be great.

All the best
B
Back to top
Ian Wilson
Guest





PostPosted: Wed Dec 20, 2006 7:23 pm    Post subject: Re: Possible JDBC installation or usage problem in OS X Reply with quote



barry_normal wrote:
Quote:
I'm having a terrible time trying to use the JDBC in os x.


Then I've opened my etc/profile file and added the location to the
classpath like this:

PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/mysql-connector-java-3.1.14/mysql-connector-java-3.1.14-bin.jar"
export PATH - This might be the problem but I couldn't find an
explicit example of how to do this...


CLASSPATH is not the same as PATH.
Back to top
barry_normal
Guest





PostPosted: Wed Dec 20, 2006 7:37 pm    Post subject: Re: Possible JDBC installation or usage problem in OS X Reply with quote



Hi Ian, thanks for that,

So should I just alter that same file to include the following?

CLASSPATH="/usr/mysql-connector-java-3.1.14/mysql-
connector-java-3.1.14-bin.jar"
export CLASSPATH

Does this make it the classpath Java apps will use?

Cheers
B

Ian Wilson wrote:
Quote:
barry_normal wrote:
I'm having a terrible time trying to use the JDBC in os x.


Then I've opened my etc/profile file and added the location to the
classpath like this:

PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/mysql-connector-java-3.1.14/mysql-connector-java-3.1.14-bin.jar"
export PATH - This might be the problem but I couldn't find an
explicit example of how to do this...


CLASSPATH is not the same as PATH.
Back to top
Ian Wilson
Guest





PostPosted: Wed Dec 20, 2006 10:07 pm    Post subject: Re: Possible JDBC installation or usage problem in OS X Reply with quote

A: Because it is harder to follow.

Q: Why shouldn't I post my reply above the original text?


barry_normal wrote:
(top-posting corrected)
Quote:

Ian Wilson wrote:

barry_normal wrote:

I'm having a terrible time trying to use the JDBC in os x.


Then I've opened my etc/profile file and added the location to
the classpath like this:

PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/mysql-connector-java-3.1.14/mysql-connector-java-3.1.14-bin.jar"
export PATH - This might be the problem but I couldn't find an
explicit example of how to do this...


CLASSPATH is not the same as PATH.

So should I just alter that same file to include the following?

CLASSPATH="/usr/mysql-connector-java-3.1.14/mysql-
connector-java-3.1.14-bin.jar" export CLASSPATH

Yes. Why didn't you just try it?

Quote:

Does this make it the classpath Java apps will use?

Usually.

Google for "Java classpath" then follow the sun.com or Roedy Green
links. Google is useful, I recommend you try it occasionally Smile
Back to top
barry_normal
Guest





PostPosted: Wed Dec 20, 2006 10:36 pm    Post subject: Re: Possible JDBC installation or usage problem in OS X Reply with quote

Ian Wilson wrote:
Quote:
A: Because it is harder to follow.

Q: Why shouldn't I post my reply above the original text?


barry_normal wrote:
(top-posting corrected)

Ian Wilson wrote:

barry_normal wrote:

I'm having a terrible time trying to use the JDBC in os x.


Then I've opened my etc/profile file and added the location to
the classpath like this:

PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/mysql-connector-java-3.1.14/mysql-connector-java-3.1.14-bin.jar"
export PATH - This might be the problem but I couldn't find an
explicit example of how to do this...


CLASSPATH is not the same as PATH.

So should I just alter that same file to include the following?

CLASSPATH="/usr/mysql-connector-java-3.1.14/mysql-
connector-java-3.1.14-bin.jar" export CLASSPATH

Yes. Why didn't you just try it?


Does this make it the classpath Java apps will use?

Usually.

Google for "Java classpath" then follow the sun.com or Roedy Green
links. Google is useful, I recommend you try it occasionally Smile

Hello Ian,

Well, I tried googling but just couldn't find an explanation which was
more specific than just 'edit the file' not what to put in it.

Also, I wasn't sure if it could be some slight syntactical difference
which OS X exhibits in this department. All the instructions seem to
assume a Windows machine.

I did try putting the text in as above but that didn't have any effect.
Still getting the same message so I was unclear as to whether it needed
some other info in there or something I've no clue about at all.

Cheers!
B
Back to top
Ian Wilson
Guest





PostPosted: Wed Dec 20, 2006 11:39 pm    Post subject: Re: Possible JDBC installation or usage problem in OS X Reply with quote

barry_normal wrote:
Quote:
So should I just alter that same file to include the following?

CLASSPATH="/usr/mysql-connector-java-3.1.14/mysql-
connector-java-3.1.14-bin.jar" export CLASSPATH


Quote:
Well, I tried googling but just couldn't find an explanation which
was more specific than just 'edit the file' not what to put in it.

I'm not familiar with OS X but since it is allegedly partly BSD based I
am sure you can persuade it to open a command shell and pretend it's Unix.

In which case something like this will work:

# MYSQLDIR=/usr/mysql-connector-java-3.1.14
# CLASSPATH=$MYSQLDIR/mysql-connector-java-3.1.14-bin.jar
# export CLASSPATH
# java myapp

(I only introduced MYSQLDIR to keep line lengths short for newsgroups)

Quote:

Also, I wasn't sure if it could be some slight syntactical difference
which OS X exhibits in this department. All the instructions seem to
assume a Windows machine.

The instructions for generic unix may be usable on OS X.

Quote:
I did try putting the text in as above but that didn't have any
effect. Still getting the same message so I was unclear as to whether
it needed some other info in there or something I've no clue about at
all.

OK. Your original merror essage was
SQLException: No suitable driver

I'm not familiar with MySQL but you might like to double check this line
in your code:

String conStr = "jdbc:mysql://http://mywebsite.net/myDatabase";

The "http://" bit looks suspicious to me. I'd guess at

String conStr = "jdbc:mysql://servername.eg.net:3306/myDatabase/";

Note the trailing slash!

Servername.eg.net is the name of the server and 3306 is whatever port
MySQL is configured for (I guess the default might be 3306?)

The next step is for you to write a 10-20 line Java program that simply
attempts to open a connection and close it again. If it doesn't work
post the whole Small Self-Contained/complete Compilable Example program
here.

I imagine MySQL includes such an example.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.