On Tue, 12 Mar 2002, Jianping Zhu wrote:
>
>
> I have this following code and mysql server running.
>
> //Connect to MySql Server
> try {
> Class.forName("org.gjt.mm.mysql.Driver").newInstance();
> }
> catch(Exception e){
> System.out.println("Can not get class Name");
> }
>
> try {
> c = DriverManager.getConnection //c is instance of Connection
> ("jdbc:mysql://jianping.dhs.org/evote?user=username&password=mypasswd");
> }
> catch (SQLException se){System.out.println("trouble to
> connect");}//
>
> When run this java code I get "Can not get class name" and"trouble to
> connect".
>
> What is the potential reason for this. my os is redhat 7.2
> Any suggetion appreciated.
>
>
> --------------------------------
> Jianping Zhu
> Department of Computer Science
> Univerity of Georgia
> Athens, GA 30602
> Tel 706 5423900
> --------------------------------
>
>
>
> _______________________________________________
> Redhat-list mailing list
> [EMAIL PROTECTED]
> https://listman.redhat.com/mailman/listinfo/redhat-list
>
Intenta esto :
-------------------
import java.sql.*;
public class mysql{
public static void main (String[] args){
try{
Class.forName("org.gjt.mm.mysql.Driver");
Connection con = DriverManager.getConnection
("jdbc:mysql://server/database?user=user&password=pass");
//Change server/database user and pass
Statement St = con.createStatement();
ResultSet Rs = St.executeQuery("select * from test");
while ( Rs.next()){
System.out.println ("Code: " + Rs.getString ("code"));
System.out.println ("Descrip :" + Rs.getString ("descrip"));
}
con.close();
}catch ( Exception E ){
System.out.println(E.getMessage());
}
}
}
------------------------
Make sure the mysql server is running and it's accepting TCP/IP
Connections and YOU have permisions to access
Seguimos ....
Leonel
_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list