Help with java and sql



Can someone please help me? I am getting the error message:
[MySQL][ODBC 3.51 Driver][mysqld-5.0.24a-community-nt]No database
selected

When I open up (control panel) (administrative tools) (ODBC) and click
on plantco, then configure and then test, it says success connection
was made, but when I open command prompt and put in C:
cd\
cd j2sdk1.4.2_12\testprog
javac EXO.java
java EXO data2

I get the above error message

This is what I have put in notepad:
import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.io.*;

public class EXO {

public static void main (String [ ] args ) {

String recordInput=" ";
String sqlCommand= " ";
try {
String url="jdbc:odbc:plantco";
String user="root"; // The user name
String password=""; // The password
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection(url,
user, password);

Statement
sttmnt=conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);

String filename="";
if (args.length > 0)
{
filename = args [0];//Filename
}
else
{
System.out.println("Must supply a file name!");
System.exit(0);
}
BufferedReader inputFile=new BufferedReader
(new FileReader(filename + ".txt"));
sttmnt.executeUpdate("DROP TABLE WinesList");
recordInput=inputFile.readLine();// Read 1st record

sqlCommand="CREATE TABLE WinesList " + recordInput;
//Create SQL statement

sttmnt.executeUpdate(sqlCommand);
//Execute SQL statement

while ((recordInput = inputFile.readLine()) != null)
{
sqlCommand = "INSERT INTO WinesList (Name_wine," +
" on_hand, " + "Color_wine, Cost)";
sqlCommand += "values (" + recordInput + ")";

sttmnt.executeUpdate (sqlCommand); //Execute SQL
System.out.println(sqlCommand);

} // end of while


sttmnt.close();// Close the Statement object
} // end of try

catch ( SQLException s) {// Process SQLException
JOptionPane.showMessageDialog(null, s.getMessage(),
"Database error",
JOptionPane.ERROR_MESSAGE );
System.exit(0);
} // end of catch

catch ( Exception e) {//All other exceptions
JOptionPane.showMessageDialog(null,
e.getMessage( ),
"Driver not found error",
JOptionPane.ERROR_MESSAGE );
System.exit(0);
} //end of catch
} //end of main
} //end of class

Can someone please help me. I have tried everything I can think of,
and looked at several totorials, but I cannot find anything to help me.
Thanks,
Debbie

.



Relevant Pages

  • Re: newbie - get memory error message when close .exe
    ... I get no error message when I click the "X" at top right ... > window to close on my laptop running XP, ... > a recordset and use a sql statement to populate the flexgrid. ... >> Veign's Resource Center ...
    (microsoft.public.vb.general.discussion)
  • Re: 2 table Query Error
    ... Post the SQL statement of the query that is giving you this error. ... It is a Country club member accounting database. ... > member ID to member ID) I get the afore memtioned error message. ...
    (microsoft.public.access.queries)
  • Re: Error syntax in Query SQL
    ... > I made application where is a part of code using SQL syntax with ADODB ... I get error message at SQL Statement when It used in other machine ... > that was choose regional setting by Indonesia (OS: ...
    (microsoft.public.vb.database)
  • Re: Visual Studio Incorrect Syntax Near The Keyword Default Information
    ... as you haven't shown us the SQL statement it's difficult to say what the ... > I have got a error message while I run a sample OLEDB program. ... > says "Incorrect Syntax Near The Keyword Default Information". ... somebody says the reason is the database file size up ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Inline CrossTab Query
    ... The SQL I used I just copied from the three queries in the Query Design ... >> I am trying to produce a SQL statement to bring together 3 queries ... >> I am getting an error message that says there is an Error in the ...
    (microsoft.public.access.queries)