Connect java(netbeans) with mysql
Posted by: Pascariu Codruta
Date: April 17, 2012 04:53AM

Hy,

I'm a beginner and I would like some help with the connection of java and mysql.
So, I included in my project's library the mysql jdbc driver, and I used the following code to make happening the connection between thoe two:

"
try{
String dbURL="jdbc:mysql://localhost/aplicatie_economica";
String user="";
String pass="";
Class.forName("com.mysql.jdbc.Driver");
Connection c=DriverManager.getConnection(dbURL,user,pass);
Statement s=c.createStatement();
ResultSet r=s.executeQuery("select distinct den_cli from clienti");
while(r.next()){
cif_cli=r.getString(1);
den_cl=r.getString(2);
adr_cli=r.getString(3);
judet=r.getString(4);
nrOrc=r.getString(5);
cont_cli=r.getString(6);
banca_cli=r.getString(7);
reprezentant_cli=r.getString(8);
calitate_reprez_cli=r.getString(9);
}
r.close();
s.close();

}
catch(ClassNotFoundException a){}
catch(SQLException a){}
" and then I print those variables, but it doesnt work...

What else do I have to do??

Options: ReplyQuote


Subject
Written By
Posted
Connect java(netbeans) with mysql
April 17, 2012 04:53AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.