BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

JAR File Error

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder Deployment
View previous topic :: View next topic  
Author Message
vichet
Guest





PostPosted: Wed Sep 06, 2006 8:13 am    Post subject: JAR File Error Reply with quote



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





PostPosted: Wed Sep 06, 2006 6:57 pm    Post subject: Re: JAR File Error Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder Deployment All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.