aspose file tools*
The moose likes JDBC and the fly likes Assistance Needed Setting up First JDBC Program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Assistance Needed Setting up First JDBC Program" Watch "Assistance Needed Setting up First JDBC Program" New topic

Assistance Needed Setting up First JDBC Program

David Yu

Joined: Oct 28, 2006
Posts: 24
Hi everyone,

I am a beginner in JDBC and in the process of setting up a simple test program. I successfully installed MySQL, j2sdk1.4.2_13 that comes with JDBC as well as JConnector.

When I attempt to run the following program in Eclipse as a "Java Application", a window appeared asking me to select the Java application. The default matching type "Activation - sun.rmi.server". I went with the default and received the following error message. I am sort of confused on what to do. Any assistance will be greatly appreciated.

Activation.main: warning: sun.rmi.activation.execPolicy system
property unspecified and no ExecPermissions/ExecOptionPermissions
granted; subsequent activation attempts may fail due to unsuccessful
ExecPermission/ExecOptionPermission permission checks. For
documentation on how to configure rmid security, refer to:

Activation.main: an exception occurred: Port already in use: 1098; nested exception is: Address already in use: JVM_Bind
java.rmi.server.ExportException: Port already in use: 1098; nested exception is: Address already in use: JVM_Bind
at sun.rmi.transport.tcp.TCPTransport.listen(
at sun.rmi.transport.tcp.TCPTransport.exportObject(
at sun.rmi.transport.tcp.TCPEndpoint.exportObject(
at sun.rmi.transport.LiveRef.exportObject(
at sun.rmi.server.UnicastServerRef.exportObject(
at sun.rmi.registry.RegistryImpl.setup(
at sun.rmi.registry.RegistryImpl.<init>(
at java.rmi.registry.LocateRegistry.createRegistry(
at sun.rmi.server.Activation.main(
Caused by: Address already in use: JVM_Bind
at Method)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createServerSocket(
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createServerSocket(
at sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(
at sun.rmi.transport.tcp.TCPTransport.listen(
... 8 more

Test Program:

import java.sql.*;

public class JDBCtest {
public static void main(String args[]){
"Copyright 2004, R.G.Baldwin");
try {
Statement stmt;

//Register the JDBC driver for MySQL.

//Define URL of database server for
// database named mysql on the localhost
// with the default port number 3306.
String url =

//Get a connection to the database for a
// user named root with a blank password.
// This user is the default administrator
// having full privileges to do anything.
Connection con =
url,"root", "password");

//Display URL and connection information
System.out.println("URL: " + url);
System.out.println("Connection: " + con);

//Get a Statement object
stmt = con.createStatement();

//Create the new database
//Register a new user named auser on the
// database named JunkDB with a password
// drowssap enabling several different
// privileges.
"ON JunkDB.* TO 'auser'@'localhost' " +
"IDENTIFIED BY 'drowssap';");
}catch( Exception e ) {
}//end catch
}//end main
}//end class
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Address already in use: JVM_Bind

The application you are running is trying to use a port that is already in use. Given the port, are you sure you are running your application from Eclipse, and no something else like Tomcat?

Depending on your operation system, you should have a tool to discover what ports are in use by what processes. If its Windows use netstat.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
David Yu

Joined: Oct 28, 2006
Posts: 24
Finally figured out what the problem was. Hooray!

It turns out that the default compiler of Eclipse is set to "5.0". After setting that to "1.4", code is able to work properly with J2SE 1.4.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 30762

Thanks for posting the solution so that others who see this thread in the future can benefit.

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Assistance Needed Setting up First JDBC Program