4 Replies - 783 Views - Last Post: 30 November 2011 - 06:46 PM Rate Topic: -----

#1 AOM_Set  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 151
  • Joined: 18-December 10

Connecting to a MySQL (non java) database

Posted 30 November 2011 - 08:30 AM

Hi. I have a Webhotel at Unoeuro.com, where I also have a MySQL data base. Though they do not offer that you can use java, they only offer .NET and php to connect to the MySQL database.
I have talked to them, and they say that it is possible to connect to the database from where I run my java program. Later it hit me that I actually don't know what this means exactly.
Can I alter, update etc. my tables in the database using java?

How do I connect to it. Say I have this MySQL information:
Hostnavn: mysql8.unoeuro.com
Username: myName_net
Password: IamKaiTw
Database myName_net_db

And I have the java code below. How do I fill in the missing part to connect? (Do not mind the MySQL statements), the issue is loading the driver etc

public static void main(String[] args) {
		try{
			Class.forName("what should be here?????").newInstance(); //Load the driver
			Connection conn = DriverManager.getConnection("mysql8.unoeuro.com, myName_net, IamKaiTw");
}



How do I find out what the argument to the Class.forName() should be??
Thanks in advance

This post has been edited by AOM_Set: 30 November 2011 - 08:52 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Connecting to a MySQL (non java) database

#2 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1820
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Connecting to a MySQL (non java) database

Posted 30 November 2011 - 09:54 AM

So your problem is how you can connect to MySQL database?
You need to pass the driver to be loaded, now depends on the driver you are using to do the connection.
We have a lot of Java to MySQL connection tutorials here:
Java to MySQL Connection ( Using the JDBC-ODBC bridge)
Using MySQL with Java
Also other tutorials may be useful:
Using JDBC to connect to MySQL from Java Program
Establishing a Connection - Oracle Database connection tutorial series.
Was This Post Helpful? 1
  • +
  • -

#3 AOM_Set  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 151
  • Joined: 18-December 10

Re: Connecting to a MySQL (non java) database

Posted 30 November 2011 - 10:25 AM

View Postsmohd, on 30 November 2011 - 09:54 AM, said:

So your problem is how you can connect to MySQL database?

My problem is how I can connect to this specific database.
[/quote]

View Postsmohd, on 30 November 2011 - 09:54 AM, said:

We have a lot of Java to MySQL connection tutorials here:

I know, but they all use the free database that you can download.

View Postsmohd, on 30 November 2011 - 09:54 AM, said:

You need to pass the driver to be loaded, now depends on the driver you are using to do the connection.

I know, but how do I find out what driver, and where to find it?
Was This Post Helpful? 0
  • +
  • -

#4 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1820
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Connecting to a MySQL (non java) database

Posted 30 November 2011 - 10:57 AM

Quote

My problem is how I can connect to this specific database.

I dont see the specific which you are talking about, you use MySQL dbms and all of those tutorials teach you to connect to any MySql database.

Quote

I know, but they all use the free database that you can download.

That is not a database, that is a driver which you will will help you to do the connection. You have to download and import in your project so you can connect to MySQl.
And so you have to differentiate between database, DBMS and DB Connectors.

Quote

I know, but how do I find out what driver, and where to find it?

Follow those tutorials and you will see what driver to use and where to find them.
Also you can follow this simplified tutorials

This post has been edited by smohd: 30 November 2011 - 11:01 AM

Was This Post Helpful? 1
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8343
  • View blog
  • Posts: 31,890
  • Joined: 06-March 08

Re: Connecting to a MySQL (non java) database

Posted 30 November 2011 - 06:46 PM

View PostAOM_Set, on 30 November 2011 - 01:25 PM, said:

View Postsmohd, on 30 November 2011 - 09:54 AM, said:

So your problem is how you can connect to MySQL database?

My problem is how I can connect to this specific database.


The DriverManager class has a static method getConnection() to which you pass as parameters:
- the URL of the database
- username
- password

http://docs.oracle.c...ava.lang.String, java.lang.String, java.lang.String)

This link shows how to load the driver

http://www.java2s.co...iverManager.htm
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1