Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old May 6th, 2001, 08:16 AM
rnth79 rnth79 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 2 rnth79 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Urgent Help Needed

Hie thr,
I am new towards Java Servlet Programming.
I am trying to make a connection to mySql database so that I could insert/update/retrieve/delete database. The problem is, I donnu how to make the connection. Is there any files that I should import before making the connection?what other procedures/statement/coding should I put in order to make the connection?
Help is really needed.
Thanks.

Randy

Reply With Quote
  #2  
Old May 6th, 2001, 08:23 PM
TonyA TonyA is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Rep. of Ireland
Posts: 2 TonyA User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This is the basis of it, you'll need to know the name of the MYSQL driver your host is using and change it accordingly.
You'll also need to know the URL of the database, this should also be available from your host.
You can plug this into any Servlet or JSP


Firstly import java.sql.*; into your program, along with whatever else your importing.

PHP Code:
//Credentials for connecting to  database
String url "jdbc:mysql://someurl";
String user "username;
String pass = "
password";


//Attempt connection & catch any errors that occur
try
{
 Class.forName( "
org.gjt.mm.mysql.Driver" );//MySQL driver
 connection = DriverManager.getConnection(url, user, pass );
}

catch ( ClassNotFoundException cnfex )
{
 System.err.println( "
Failed to load JDBC/ODBC driver." );
 cnfex.printStackTrace();
 System.exit( 1 );  // terminate program
}

catch ( SQLException sqlex )
{
 System.err.println( "
Unable to connect" );
 sqlex.printStackTrace();


Reply With Quote
  #3  
Old May 20th, 2001, 05:36 PM
nickd nickd is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 4 nickd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
do a search on JDBC and you'll get lots of examples and how-to's you need to load in JDBC driver, make a connection and execute the SQL.

Nick

Reply With Quote
  #4  
Old May 24th, 2001, 11:31 PM
CyberOsc CyberOsc is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Indonesia
Posts: 87 CyberOsc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
hi.. i think you need MySQL JDBC driver ....
You can download it from www.worldserver.com/mm.mysql/
__________________
** Science belongs to the world **

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Urgent Help Needed


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway