File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Database on MySQL Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Database on MySQL Server" Watch "Database on MySQL Server" New topic

Database on MySQL Server

kashinath lagdive

Joined: Jul 13, 2008
Posts: 2
Dear Friends,
I have following SQL code for database:

"Statement stmt=con.createStatement();
boolean b=stmt.execute("CREATE TABLE user(emailid VARCHAR(30) NOT NULL, password VARCHAR(12), PRIMARY KEY(emailid))");"

which is not executing on my mysql server database. giving exception like this :
root cause :

How can i create table in my MySql database on remote server.
Connection is getting establised properly.How can i eliminate this Exception.Code is successfully running on my local machine and Localhost database server.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

NullPointerException is a problem with Java and not MySQL. Can we see some more code? How do you get your Connection?
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

"ksl lagdive"

Please refer to the JavaRanch naming policy and update your name appropriately.

[OCA 8 Book] [Blog]
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46424
The message says the root cause is a NullPointerException (NPE).
Some people say the NPE is the commonest and most annoying mistake in Java. This is obviously discussed often on JavaRanch. The first thing to do is to get more details (as David has told you). Find where that occurs and put lots of informative code in the catch block, including exc.printStackTrace(); (where "exc" is what you wrote in the () after catch). Follow the stack trace back to where you might have something which is null.

Do a search and you get useful old posts like this, this, this, and there will be lots more. Read those threads; what you are interested in is not what happened, but how we suggested they sort out their NPEs. You need to do the same.
kashinath lagdive

Joined: Jul 13, 2008
Posts: 2
thank you very much sir,
Just there is minor mistake in my code in my connection
object, exception gets resolved successfully.
code is working properly.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46424
Originally posted by kashinath lagdive:
thank you . . . code is working properly.
Well done
[ July 21, 2008: Message edited by: Campbell Ritchie ]
It is sorta covered in the JavaRanch Style Guide.
subject: Database on MySQL Server
It's not a secret anymore!