Win a copy of Rust Web Development this week in the Other Languages forum!

Kalyan Ram

Greenhorn
+ Follow
since Dec 29, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kalyan Ram

Joonas Järvinen wrote:If you mean if that port is beign listened. Then I would guess yes. This is from 'netstat -a'
TCP 0.0.0.0:3306 My-PC:0 LISTENING
And MySQL query browser also connect to the db using that port. Also the abcuser has every access possible to give in my db server.


You missed Scholtz's advise.

Your java code is being executed by the run time (java.exe). The firewall will see java.exe trying to network. So check your firewall/s and see if java.exe (or equivalent for your OS) has permissions to network.

static String url = "jdbc:mysql://localhost:3306";

is fine. BTW you can make this string final too.

Arvind Subramanian wrote:
everything i want to store in the application scope instead of cookies or sesssion.

Can anyone tell me best practise for it?


javax.servlet.http.HttpSession (J2EE 1.4)

Session information is scoped only to the current web application (ServletContext), so information stored in one context will not be directly visible in another.

Doesn't that suffice?

I think I am in the same place as the parent
12 years ago

shyamkumar bopannachengalaiah wrote: I am developing registration application where i have to store the creation date of the enduser in database. here the creation date should be server date. How can i write the code in my servlet to get the serverdate and insert into the mysql database?


Is there any specific need for this particular approach? i.e. taking Servlet host's time as the user creation time.

Are the application server and DB server in different timezones? Is there substantial network lag between the application and database servers? Are the user creation SQL statements executed as a batch?

If none of the above cases apply, then simply use the database's now() or similar function as the user creation time i.e. the time when the table row was inserted is taken as the user creation time.

In most cases the user creation date need not be anything beyond something like 08-Apr-2009, 17:09:03. But your requirement might require finer detail?
[edit]
BTW, if you choose to follow the parent's advise, take a look at both java.util.Date/Time and java.sql.Date/Time/Timestamp


regards
/k
12 years ago
Call your host and find out if they permit remote connections to MySQL.

If you already have permission to make a remote connection, ask the host for the IP address and port of the mysql server machine. With those details try the following -

DriverManager.getConnection("jdbc:mysql://xxx.xxx.xxx.xxx:PORT_NUMBER/YOUR_DB_NAME?" + "user=USER_NAME&password=YOUR_PASSWORD")
xxx.xxx.xxx.xxx is the IP address

IMHO chapter 20.4. MySQL Connector/J will be very helpful.


regards
/k
As the parent said, you have java.net.ConnectException very early in the stack.

-Are you able to connect to the local mysql server via command line?
-Do you have the appropriate permissions in mysql.user table?
-If mysql isn't listening on the standard port (3306), then the port must be part of the database URL

@Rohankar
20.4.5.1.1 of MySQL manual says


// The newInstance() call is a work around for some broken Java implementations
Class.forName("com.mysql.jdbc.Driver").newInstance();


so newInstance() should not be the culprit?

Like Scholtz, I too am interested in the reason behind your advise. Have you heard of any instances where newInstance() broke the application?

regards
/k

Sudhakar Kumar wrote:Here one thing, I forgot to mention that the context is for LDAP not for DB. I know how to make manage connection using for DB but I don't know how to use it for LDAP.


errr since you are still dealing with j.l.Object, maybe you could use Commons Pool - http://commons.apache.org/pool/

Ramaprasad Kolla wrote:
Hi Kalyan,

That was a typo mistake. I have even tried installing the things in no-space named folders but still of no use.

Thanks,
Ramaprasad Kolla


Couple of quick questions -
* what is the path to your JSP file?
For instance, if your JSP is put in TC_HOME\webapps\jsp-examples and accessed via http://localhost:8080/jsp-examples/your_jsp.jsp does it still fail?
* What did you use to install tomcat, the installer or the archive?
* try acidjnk's work around @ http://forums.sun.com/thread.jspa?threadID=494649
Does that too fail?
* did you find any clues in the logs @ TC_HOME\logs

regards
/k
12 years ago

Bauke Scholtz wrote:

Kalyan Ram wrote:
FWIW, I don't even have the CATALINA_HOME setting on my XP PRO SP3 PC.


It is only required when you run Tomcat standalone (and thus not from within some external tool like an IDE or so).


Please elucidate.

I am using Tomcat with Notepad++ as my code editor.

I have a shortcut to tomcat5w.exe on my desktop for situations needing a server restart.

regards
/k
12 years ago

Ramaprasad Kolla wrote:
2. CATALINA_HOME = C:\Program Files\Apache Software Foundation\Tomcat 5.0\binC:\Program Files\Apache Software Foundation\Tomcat 5.0


According to the above setting, Tomcat is residing at two places. That doesn't make sense.

C:\Program Files\Apache Software Foundation\Tomcat 5.0\bin should be in the PATH, because the bin directory (by convention) points to the executable files.
C:\Program Files\Apache Software Foundation\Tomcat 5.0 is the correct CATALINA_HOME

I don't know if its a typo or something else, but file paths should be separated by a semi-colon.

FWIW, I don't even have the CATALINA_HOME setting on my XP PRO SP3 PC.

I would definitely try out the Koster's advise regarding paths with spaces. Uninstall JDK and Tomcat from current locations. Re-install them into locations with no spaces like c:\jdk1.6.0_10 & c:\Tomcat-5.0

This link might have suggestions - http://wiki.apache.org/tomcat/FAQ/Miscellaneous#Q1
12 years ago
http://hsqldb.org/doc/hsqlFindFile.html

The FindFile.java, in your post, isn't extending a Servlet. OTOH its got a main()

Am I missing something?


hth
/k

[ September 20, 2008: Message edited by: Kalyan Ram ]
[ September 20, 2008: Message edited by: Kalyan Ram ]
What were the expected and actual outputs?

/k
13 years ago
Sorry not a useful response.

Just a question for my clarification - why GMT offset? won't java.util.SimpleTimeZone work?

Maybe your need might be filled with Joda Time if you aren't constrained from using ASF-licensed code.

regards
Kalyan
[ September 01, 2008: Message edited by: Kalyan Ram ]
13 years ago
Salil, if you do as the Sachin says you don't have to configure anything in the web.xml.

OTOH, if you want to configure MySQL as JNDI resource then check Tomcat's documentation or click here -> mysql datasource in tomcat

regards
Kalyan
[ August 26, 2008: Message edited by: Kalyan Ram ]
13 years ago

Originally posted by Kim Kantola:
Ooh, by profiler do you mean something like Fiddler?


No, I think Steve Luke meant something like -> http://profiler.netbeans.org/
13 years ago