 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
vichet Guest
|
Posted: Wed Sep 06, 2006 8:13 am Post subject: JAR File Error |
|
|
Dear All;
please help!
Let me explain you first about my problem
1- connectToMySqlJoke
------------------------------
import java.sql.*;
public class connectToMySqlJoke {
private String serverHost;
private String port;
private String userName;
private String password;
private String schema;
private Connection connection=null;
private Boolean connected;
public connectToMySqlJoke(){
this.serverHost="localhost";
this.port="3306";
this.userName="root";
this.password="123456";
this.schema="jokedb";
Connect();
}
public void Connect(){
String connStr = "";
try {
Class.forName("com.mysql.jdbc.Driver");
connStr="jdbc:mysql://"+ this.serverHost +":";
connStr+=this.port + "/" + this.schema;
connection =
DriverManager.getConnection(connStr,this.userName,this.password);
this.connected=true;
}
catch (SQLException e){
this.connected=false;
//System.out.println("Sql error");
}
catch (ClassNotFoundException e){
this.connected=false;
//System.out.println("jdbc driver not found!");
}
}
public Connection getConncetion() {
return connection;
}
public void closeConnection(){
try {
connection.close();
}
catch (Exception e){}
}
public Boolean IsConnected(){
return this.connected;
}
}
2- TestConnection
---------------------
public class TestConnection {
public static void main(String[] args) {
connectToMySqlJoke mycnt=new connectToMySqlJoke();
System.out.print(mycnt.IsConnected());
}
}
Yes, it works after i compile it and it returns TRUE. it connects.
But after i make JAR file. it do not work. i wonder why?
I make like this:
My mainClass file contain: Main-Class: TestConnection
jar cmf mainClass Test.jar *.class
then i run
java -jar Test.jar
it return false
help help |
|
| Back to top |
|
 |
Paul Furbacher [TeamB] Guest
|
Posted: Wed Sep 06, 2006 6:57 pm Post subject: Re: JAR File Error |
|
|
vichet wrote:
| Quote: | [..]
Yes, it works after i compile it and it returns TRUE. it connects.
But after i make JAR file. it do not work. i wonder why?
I make like this:
My mainClass file contain: Main-Class: TestConnection
jar cmf mainClass Test.jar *.class
then i run
java -jar Test.jar
it return false
|
Please post in only one newsgroup, according to newsgroup
guidelines. I answered your question in the other newsgroup,
"language" because that's the one I saw first. The correct
newsgroup is actually this one, "deployment".
--
Paul Furbacher (TeamB)
Save time, search the archives:
http://info.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you. |
|
| Back to top |
|
 |
|
|
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
|
|