Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Eclipse juno console error message.(Eclipse juno console error message. Java swing & sqlite used.)
Eclipse juno console error message. [message #1583728] Sun, 25 January 2015 10:06 Go to next message
Nandan M is currently offline Nandan MFriend
Messages: 9
Registered: November 2014
Junior Member
I am using Eclipse juno and have created a simple java project with sqlite connection. The details of the same are as mentioned below.

There are only two files in my project and the first one is named as sqliteConnection.java and the code it contains is as mentioned here:

import java.sql.*;
import javax.swing.*;
public class sqliteConnection {
Connection conn=null;
public static Connection dbConnector ()
{
try{
Class.forName("org.sqlite.JDBC");
Connection conn=DriverManager.getConnection("jdbc:sqlite:C:\\Users\\nandan.m\\workspace\\EmployeeData.sqlite");
JOptionPane.showMessageDialog(null, "Successful Connection");
return conn;
}catch(Exception e)
{
JOptionPane.showMessageDialog(null, e);
return null;
}
}
}

My second file is named as Login.java and the code it consists as mentioned below:

import java.awt.EventQueue;

import javax.swing.JFrame;
import java.sql.*;
import javax.swing.*;


public class Login {

private JFrame frame;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Login window = new Login();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

Connection connection=null;



/**
* Create the application.
*/
public Login() {
initialize();
connection=sqliteConnection.dbConnector();

}

/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

}



The console error message I receive on the eclipse is as mentioned below:

Usage: javaw [-options] class [args...]
(to execute a class)
or javaw [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
-hotspot is a synonym for the "server" VM [deprecated]
The default VM is server.

-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://java.sun.com/javase/reference for more details.

I have also created a folder called resources in which I have imported all selite-jdbc jar files from here. URL:www.bitbucket.org/xerial/sqlite-jdbc/downloads.

Kindly let me know if there are any changes required in my code/editor/jar files in order to resolve the problem which I get as the console error message. The expected message is "Connection successful".
Re: Eclipse juno console error message. [message #1584274 is a reply to message #1583728] Sun, 25 January 2015 17:32 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

What are you doing when you get this console error message? Are you
trying to execute main()?
Re: Eclipse juno console error message. [message #1585635 is a reply to message #1584274] Mon, 26 January 2015 11:36 Go to previous messageGo to next message
Nandan M is currently offline Nandan MFriend
Messages: 9
Registered: November 2014
Junior Member
Sir,
That's a good question! That is one thing I missed out mentioning it here, I was trying to run sqliteConnection.java that is when I receive the console error message. I also get an alert saying java update is ready to install once I login but I have not installed them at all.
Is this the reason why I am getting this error message.
However, to tell you in detail what I did is as follows:
Step1: I created a java project by name: Company, then I went to the src(source) folder to create a class which I called as sqliteConnection which would help us to connect to the database in this I unchecked the public static void main(String[] args) as I did not want it contain this main method.
Step2: Once the sqliteConnection class was created it did not have anything other than the class name.
Step3: Then I imported java.sql.*; secondly I imported javax.string.*. I then created a public method which would return the connection and gave it a name as dbConnector without any arguments.
Step 4: I created a global variable "Connection conn=null" which was a part of java.sql.Connection class which would return the connection.
Step5: I created a try catch block which would take exception. If there is any exception that would occur then I would be showing that in Joption pane.showmessageDialouge. In the JoptionPane my first argument was null and the second argument was the exception error message.
Step6: In the try block I defined the class for the connection to the SQlite Class.forName("org.sqlite.JDBC"); once we return connection the error message will be shown. Then created a connection conn=DriverManager.getConnection("jdbc:databasename(sqlite):path-of-my-database-by-specifying-doubleslash-as-it-is-on-windows").
Step7: I then return connection by saying return conn; and return null;.
Step8: I then created the login form. On the src(source) folder I right click and choose other where I choose windowBuilder under Swing Designer I choose Application Window then I gave the name of the new class as "Login".
Step9: In the constructor for Login class which is public Login which already had initialize method which was generated by eclipse. Just below the initialize method I call that class java connection class to check my connection.
Step10: Imported the required library which are import java.sql.*; & import javax.swing.*;.
Step11: Just after declaration of the frame or above the constructor "Login" which has the same name as my class and which has the initialize method. Include the Connection connection and set it to null.
This will be connection to the database.
Step12: I call the connection object = name of the class which in my case is sqliteConnection class.method which is dbConnector method which is specified in our sqliteConnection.java file.
Step13: Include one more message before returning connection saying that the connection is successful.
Specify this just above return connection in sqliteConnection.java file.
Step14: In Login class we have just Connection class from java.sqlite class and in the constructor of the login class we have just called
Connection=the class(sqliteConnection).the method in which I have connected to the database(dbConnector)
Step15: Then I right clicked to check if I could make this project as my Main project. I then thought again and once I clicked on the "Run" we should be able to choose that.

This is when I received the error message. I am sure that I have briefly described in steps what I have done. Kindly advise an immediate solutions for the same.
Awaiting for your reply.
Re: Eclipse juno console error message. [message #1585867 is a reply to message #1585635] Mon, 26 January 2015 14:33 Go to previous message
Nandan M is currently offline Nandan MFriend
Messages: 9
Registered: November 2014
Junior Member
No you I did not try to execute main().
Previous Topic:Newbee pitfalls
Next Topic:Eclipse for Python
Goto Forum:
  


Current Time: Thu Apr 25 05:58:09 GMT 2024

Powered by FUDForum. Page generated in 0.09168 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top