Java.sql problem

Hi,
I have a problem with "import java.sql.*".
When a try to compile i get the error:
"package java.sql does not exist"
I've tried everything, classpath, add JAR/Libraries, install CDC tools, looked into hundred forums and can't solve the problem.
I'm using NetBeans 5.5 with Mobility Pack.
If anybody have any idea about what can I do, I'll appreciate it a lot.
Thank You!
If you need me to be more specific, please let me know

I just start the application with
import java.sql
an then the rest of the applicationIf you want to import all the classes from the java.sql package, the correct import statement is:import java.sql.*;� {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Problem with java.sql.Clob and oracle.sql.CLOB

    Hi,
    I am using oracle9i and SAP web application server. I am getClob method and storing that in java.sql.Clob and using the getClass().getName() I am getting the class name as oracle.sql.CLOB. But when I am trying to cast this to oracle.sql.CLOB i am getting ClassCastException. The code is given below
    java.sql.Clob lOracleClob = lResultSet.getClob(lColIndex + 1);
    lPrintWriter = new PrintWriter(new BufferedWriter (((oracle.sql.CLOB) lOracleClob).getCharacterOutputStream()));
    lResourceStatus = true;
    can anybody please tell me the what is the problem with this and solution.
    thanks,
    Ashok.

    Hi Ashok
    You can get a "ClassCastException" when the JVM doesn't have access to the specific class (in your case, "oracle.sql.CLOB").
    Just check your classpath and see if you are referring to the correct jar files.
    cheers
    Sameer
    PS: Please award points if you find the answer useful

  • Problem Writing java.sql.Date to MS Access

    I have a relatively simple application that is for my own use (not distributed on an enterprise-wide basis). As I don't have an IT staff, I'm using a rudimentary Java front-end (v1.3.1) and a Microsoft Access backend.
    I seem to have trouble using INSERT/UPDATE statements with the MS Access Date/Time data type. Below is an example of code being used (id is defined as Text, amount is a Number and timestamp is Date/Time):
    conn = DriverManager.getConnection("jdbc:odbc:markets", "", "");
    conn.setAutoCommit(true);
    String sql = "INSERT INTO temp (id, amount, timestamp) VALUES (?, ?, ?)";
    PreparedStatement stmt = conn.prepareStatement(sql);
    String id = args[0];
    int len = id.length();
    java.sql.Date dt = new java.sql.Date(new java.util.Date().getTime());
    stmt.setString(1, id);
    stmt.setDouble(2, id.length());
    // I think the problem is here - the JDBC driver doesn't properly map dates to Access???
    stmt.setDate(3, dt);
    stmt.execute();
    stmt.close();
    conn.close();And I get the following error:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access
    Driver] Syntax error in INSERT INTO statement.
            at sun.jdbc.odbc.JdbcOdbc.createSQLException (JdbcOdbc.java:6879)
            at sun.jdbc.odbc.JdbcOdbc.standardError (JdbcOdbc.java:7036)
            at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect (JdbcOdbc.java:3065)
            at sun.jdbc.odbc.JdbcOdbcStatement.execute (JdbcOdbcStatement.java:338)
            at TestWritingDate.main(TestWritingDate.java:31) I'm virtually certain this is a translation problem with
    the java.sql.Date and the JDBC driver. But I can't seem
    to overcome this. Any help is DESPERATELY needed.
    Thanks.
    Matt

    That was it....thanks...didn't even consider that....perhaps I should start using class names that are already in use too :-). Thanks again...

  • Problem in addBatch method in java.sql.Statement Interface

    Hi
    I am facing a problem java.lang.UnsupportedOperationException when using addbatch() method of java.sql.Statement Interface.
    Please suggest solutions.
    Thanks
    nsgindia

    Your JDBC driver doesn't support batch operation, try another driver(not all databases support batch'es eg MySQL)

  • SQL Server 2000 - JDBC + Java Applet problem

    Hai
    I have some problem connecting my SQL server database with Java.
    I use Applet to make my interface.
    I use Windows 2000 server.
    Here is my program listing :
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.sql.*;
    public class VLookup extends JApplet {
    String database = "jdbc:odbc:Driver={SQL Server};SERVER=Windows2000;uid=sa;pwd=;Database=User-Phone Database";
    String user = "sa";
    String password = "";
    Statement s;
    Connection c;
    JTextField searchFor = new JTextField(10);
    JLabel completion = new JLabel(" ");
    JTextArea results = new JTextArea(40, 20);
    public void init() {
    searchFor.getDocument().addDocumentListener(new SearchL());
    JPanel p = new JPanel();
    p.add(new Label("ID to search for :"));
    p.add(searchFor);
    p.add(completion);
    Container cp = getContentPane();
    cp.setLayout(new BorderLayout());
    cp.add(p, BorderLayout.NORTH);
    cp.add(results, BorderLayout.CENTER);
    try {
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    c = DriverManager.getConnection(database, user, password);
    s = c.createStatement();
    } catch(Exception e) {
    results.setText(e.getMessage());
    class SearchL implements DocumentListener {
    public void changedUpdate(DocumentEvent e){}
    public void insertUpdate(DocumentEvent e){
    textValueChanged();
    public void removeUpdate(DocumentEvent e){
    textValueChanged();
    public void textValueChanged() {
    ResultSet r;
    if(searchFor.getText().length() == 0) {
    completion.setText("");
    results.setText("");
    return;
    try {
    r = s.executeQuery("SELECT " + "Tipe " + "FROM " + "Time " + "WHERE " + "(Tipe Like '" + searchFor.getText() + "%') "
    + "GROUP BY " + "Tipe " + "ORDER BY " + "Tipe " );
    if(r.next())
    completion.setText(r.getString("Tipe"));
    r = s.executeQuery("SELECT " + "ID_Pengguna, Phone_Number, Tipe " + "FROM " + "Time "
    + "WHERE " + "(Tipe ='" + completion.getText() + "') "
    + "GROUP BY " + "ID_Pengguna, Phone_Number, Tipe "
    + "ORDER BY " + "ID_Pengguna, Phone_Number " );
    } catch(Exception e) {
    results.setText(searchFor.getText() + "\n");
    results.append(e.getMessage());
    return;
    results.setText("");
    try {
    while(r.next()) {
    results.append(r.getString("ID_Pengguna") + ", " + r.getString("Phone_Number") + ", " + r.getString("Tipe") + "\n");
    } catch(Exception e) {
    results.setText(e.getMessage());
    public static void main(String[] args) {
    JApplet applet = new VLookup();
    JFrame frame = new JFrame("User ID");
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e){
    System.exit(0);
    frame.add(applet);
    frame.setSize(500, 200);
    applet.init();
    applet.start();
    frame.setVisible(true);
    } ///:~
    And java catch error like this : access denied (java.lang.RuntimePermission access ClassInPackage.sun.jdbc.odbc)
    What is wrong ??
    Is there any problem with my DNS ? 'cos I don't know how to set up my DNS.
    Can u help my with this problem ??
    Thank's

    You need to read up on what applets are capable of. Applets generally cannot open connections to things like databases due to sandboxing. There are a couple of ways to get around this. The applet can connect to a servlet on the same machine from which it came and have the servlet do the database accesses. Alternately, you can create a signed applet which allows you to get around some of these sandboxing issues.If tried to make localhost on my computer ( by setting my IIS configuration setting, and using Configure SQL XML Support in IIS I've created a new http://localhost/skripsi to my SQL database.
    Is there any command that I have to add to my program listing so the applet can work as I wish ??
    Is there any way to use applet to connect my database withaout using servlet, and can u explain siggned applet to mey ??
    Sorry, I don't really know java very well.
    driver type 4 ??

  • Java.sql.SQLException: No suitable driver problem

    Hello all.
    Firstly, i am new to programming java apps that connect to SQL databases.
    I have set up a MySQL server on my computer, which i can successfully access through my command prompt on my pc (so i know its up and running). Now im trying to create a simple java program which connects to the sql database, and simply lists the contents of the table in question. However, when running this program i recieve this exception:
    java.sql.SQLException: No suitable driver
    I have thoroughly researched this problem on the internet, with many people saying that i have not installed the j/connector driver correctly. My j/connecter driver file is in C:\Program Files\JAVASQL\mysql-connector-java-3.0.17-ga-bin.jar . My Environmental Variable CLASSPATH in windows reads: ".;C:\Program Files\Java\jre1.5.0_03\lib\ext\QTJava.zip; C:\Program Files\JAVASQL\mysql-connector-java-3.0.17-ga-bin.jar", so i am pretty sure i have done everything correctly with reguards to installing the connector.
    My program code is as follows:
       import java.sql.*;
        class TestSqlConnect
           public static void main (String[] args)
             try
                Connection sqlConnection = DriverManager.getConnection("jdbc:mysql://127.0.0.1/myDatabaseName","root","mypassword");
                Statement sqlStatement = sqlConnection.createStatement();
                ResultSet sqlResult = sqlStatement.executeQuery("SELECT * FROM Rooms");
                while (sqlResult.next())
                   System.out.println(sqlResult.getString("name"));
                sqlStatement.close();
                 catch (Exception e)
                   System.out.println(e.toString());
       }Note i have also tried the url "jdbc:mysql://localhost/myDatabaseName" and still get the same problem.
    Any help would be greatly appreciated. cheers.

    jazza_guy wrote:
    Ok problem solved! Im gonna post the answer as whilst trying to find the answer myself i found so many people had this problem... yet noone could seem to find an asnwer.Nonsense. Lots of people find an answer to this problem. You're the one having the problem.
    Altho i did have my connector class in the CLASSPATH, this was not enough..Wrong. You think you had the driver class in your CLASSPATH, but you did not. You don't understand CLASSPATH.
    The file needs to be copied into the main_java_folder/jdk/jre/lib/ext folder... and that seemed to do the trick..That might "work", but it's absolutely the wrong thing to do.
    %

  • Problem saving java.sql.timestamp

    I am using java.sql.timestamps for all date fields inside the database.
    the client program is using a session bean to insert the data into the database. Afterwards when I do a select in sql plus the date is always 2 hours and 30 minutes above the value I supplied to the database.
    Are there any timezone settings I have to supply on the server ?
    thx in advance
    null

    Please shrink your code down to the bare minimum that compiles and demonstrates the problem. Do not include any tests that pass. Just the one that fails, and describe clearly exactly how it fails--what's expected and what is observed instead.
    You can probably even get rid of the separate test class and just put it all in main, or at least all in the same class with main and one or a small handful of other methods.

  • Problems with impoting java.sql.*

    Hi.
    When I'm compiling the following code I get this message:
    SimpeltDatabaseEksempel.java:4: Package java.sql not found in import import java.sql.*
    What could be wrong?
    /lars
    Here is my code:
    import java.sql.*;
    public class SimpeltDatabaseeksempel
         public static void main(String[] arg) throws Exception
              // Udskift med din egen databasedriver og -URL
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection forb = DriverManager.getConnection("jdbc:odbc:datakilde1");
              Statement stmt = forb.createStatement();
              stmt.executeUpdate("create table KUNDER (NAVN varchar(32), KREDIT float)" );
              stmt.executeUpdate("insert into KUNDER values('Jacob', -1799)");
              stmt.executeUpdate("insert into KUNDER values('Brian', 0)");
    }

    There is no problem in your classpath but make sure that your classpath is set correctly.
    set classpath=%classpath%;C:\j2sdk1.4.2_04\lib
    or got to Environment variables and then edit the classpath vartiable and add the C:\j2sdk1.4.2_04\lib path (Respective to your system).

  • PreparedStatement.setDate(1,java.sql.Date x) problem

    I am using Sun JDBC-ODBC bridge to access MS SQL Server 2000. I have following statement:
    java.util.Date date = new java.util.Date();
    java.sql.Date expire_date = new java.sql.Date(date.getTime());
    PreparedStatement pstat = con.prepareStatement("update account set expire_date=? where userid=?");
    pstat.setDate(1,expire_date);
    pstat.setString(2,userid);
    When I ran the program, I got a SQLException error as
    java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Optional features not implemented.
    I have traced the problem happened in the statement pstat.setDate(1,expire_date). I use jdbc-odbc bridge from j2se 1.3.1.
    I appreciate any help.
    Thanks, Brian

    May I refer to a recent topic where I explained a lot about date conversion between JDBC and SQLServer?
    http://forum.java.sun.com/thread.jsp?forum=48&thread=241049
    Try how far this helps you, then ask more.

  • Accessing MS Sql Server with Java classes - problem connecting to socket

    I found an example at this location which uses java classes to connected to MS Sql Server.
    http://search400.techtarget.com/tip/1,289483,sid3_gci1065992,00.html
    --bummer - it is a login location - so I will include the article
    Anyway, the example is using Websphere, but I am still on Jbuilder (will get wsad soon). So I planted the classes from the example in
    C:\Borland\JBuilder\jkd1.4\jre\lib\ext\...the classes
    Then I copied the code from the example to my jpx project and got an error that it could not connect to the socket. The only thing I changed in the code was the connection string:
    --original string from example:
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://1433", "");
    I was getting an error with the 2 argument version of DriverManager - and the second argument here was empty (properties argument). Here was my connection string:
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://Myserver:1433;User=sa;Password=");
    I am only using the 1 argument version of DriverManager. Note that the password=" is blank because my RnD workstation is standalone - no one accesses the sql server except me - so no password. I also left out the last semicolon I noticed. Any suggestions appreciated how I could fix this.
    Thanks
    source of article:
    http://search400.techtarget.com/tip/1,289483,sid3_gci1065992,00.html
    iSeries 400 Tips:
    TIPS & NEWSLETTERS TOPICS SUBMIT A TIP HALL OF FAME
    Search for: in All Tips All search400 Full TargetSearch with Google
    PROGRAMMER
    Sample code: Accessing MS SQL Server database from the iSeries
    Eitan Rosenberg
    09 Mar 2005
    Rating: --- (out of 5)
    Nowadays with the help of Java the iSeries can be integrated with other databases quite easy. This tip shows you how. The code included here uses the free Microsoft driver that can be downloaded from here. (SQL Server 2000 Driver for JDBC Service Pack 3)
    If your SQL server does not include the Northwind Sample Database you can find it here.
    http://www.microsoft.com/downloads/details.aspx?familyid=07287b11-0502-461a-b138-2aa54bfdc03a&displaylang=en
    The download contains the following files:
    msbase.jar
    mssqlserver.jar
    msutil.jar
    Those files needs to be copied to the iSeries directories (/home/r_eitan/ExternalJARs).
    Here's the directory structure (on the iSeries) for this sample:
    /home/r_eitan/ExternalJARs - Microsoft files (msbase.jar,mssqlserver.jar,msutil.jar)
    /home/r_eitan/JdbcTest02 - My code (Main.java,Main.class)
    The Java code
    import java.sql.*;
    import java.io.*;
    class Main {
    * Connect to Microsoft SQL server and download file northWind.products as tab
    * seperated file. (products.txt)
    public static void main(String args[]) {
    try {
    PrintStream outPut = new PrintStream(new BufferedOutputStream(new FileOutputStream("products.txt")));
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    //Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://1433", "");
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://Myserver:1433;User=sa;Password=");
    System.out.println("Connection Done");
    connection.setCatalog("northWind");
    String sqlCmdString = "select * from products";
    Statement statement = connection.createStatement();
    ResultSet resultSet = statement.executeQuery(sqlCmdString);
    ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
    int columnCount = resultSetMetaData.getColumnCount();
    // Iterate throught the rows in resultSet and
    // output the columns for each row.
    while (resultSet.next()) {
    for (int index = 1; index <=columnCount; ++index)
    String value;
    switch(resultSetMetaData.getColumnType(index))
    case 2 :
    case 3 :
    value = resultSet.getString(index);
    break;
    default :
    value = """ + resultSet.getString(index) + """;
    break;
    outPut.print(value + (index < columnCount ? "t" : ""));
    outPut.println();
    outPut.close();
    resultSet.close();
    connection.close();
    System.out.println("Done");
    catch (SQLException exception)
    exception.printStackTrace();
    catch (Exception exception)
    exception.printStackTrace();
    --------------------------------------------------------------------------------------------------

    My guess is that the server's host name isn't right. It necessarily (or even usually) the "windows name" of the computer. Try with the numeric IP address instead (type "ipconfig" to see it).
    First aid check list for "connection refused":
    - Check host name in connect string.
    - Check port number in connect string.
    - Try numeric IP address of server host in connect string, in case name server is hosed.
    - Are there any firewalls between client and server blocking the port.
    - Check that the db server is running.
    - Check that the db server is listening to the port. On the server, try: "telnet localhost the-port-number". Or "netstat -an", there should be a listening entry for the port.
    - Try "telnet serverhost the-port-number" from the client, to see if firewalls are blocking it.
    - If "telnet" fails: try it with the numeric ip address.
    - If "telnet" fails: does it fail immediately or after an obvious timeout? How long is the timeout?
    - Does the server respond to "ping serverhost" or "telnet serverhost" or "ssh serverhost"?

  • Java Session problem while sending mail(using javamail) using Pl/SQL

    Hello ...
    i am using Java stored procedure to send mail. but i'm getting java session problem. means only once i can execute that procedure
    pls any help.

    props.put("smtp.gmail.com",host);I doubt javamail recognizes the 'smtp.gmail.com' property. I think it expects 'mail.host'. Of course since it cannot find a specified howt it assumes by default localhost
    Please format your code when you post the next time, there is a nice 'code' button above the post area.
    Mike

  • Problems with importing java.sql.*

    Hi.
    When I'm compiling the following code I get this message:
    SimpeltDatabaseEksempel.java:4: Package java.sql not found in import import java.sql.*
    What could be wrong?
    /lars
    Here is my code:
    import java.sql.*;
    public class SimpeltDatabaseeksempel
         public static void main(String[] arg) throws Exception
              // Udskift med din egen databasedriver og -URL
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection forb = DriverManager.getConnection("jdbc:odbc:datakilde1");
              Statement stmt = forb.createStatement();
              stmt.executeUpdate("create table KUNDER (NAVN varchar(32), KREDIT float)" );
              stmt.executeUpdate("insert into KUNDER values('Jacob', -1799)");
              stmt.executeUpdate("insert into KUNDER values('Brian', 0)");
    }

    Don't know what to tell you, except that it exists
    http://java.sun.com/j2se/1.5.0/docs/api/java/sql/package-summary.html
    What version of java are you using?

  • The problem about java.sql.CallableStatement

    we need call oracle store procedure to get a record set.
    the code below is the oracle's pl/sql program for test
    package test2 as
    type sample_record is record(id char(4),
    name varchar2(10),
    addr varchar2(30));
    type sample_cursor is ref cursor return sample_record;
    function get_resultset return sample_cursor;
    end;
    package body test2 as
    function get_resultset return sample_cursor is
    p_cursor sample_cursor;
    begin
    open p_cursor for select 'aaaa' id,'John' name,'guangzhou' addr from dual;
    return p_cursor;
    end get_resultset;
    end;
    and ,in java,how to use java.sql.CallableStatement to
    run the store procedure to get the cursor,a sql type define in our oracle programme

    see the code below,
    public static sun.jdbc.rowset.WebRowSet testmethod(){
         Connection conn = null ;
              CallableStatement cstmt = null ;
              String str = null ;
              ResultSet result = null ;
              str = "{?=call test2.get_resultset()}" ;                    
              try
                   conn = DbPool.getConnection() ;
                   cstmt = conn.prepareCall(str) ;
                   cstmt.registerOutParameter(1, OracleTypes.CURSOR);
                   cstmt.execute();
                   result = (java.sql.ResultSet)cstmt.getObject(1) ;                                             
                   sun.jdbc.rowset.WebRowSet wrs = new sun.jdbc.rowset.WebRowSet() ;
              wrs.populate(result) ;//in this statement,it will throw a NullPointerException
                   return wrs;
              catch (Exception e)
                   CommLog.writeLog("pr", "PrLogic test: " + e.toString()) ;
                   return null ;
              }finally
                   try
                        result.close() ;
                   catch (Exception e3)
                   try
                        cstmt.close() ;
                   catch (Exception e1)
                   try
                        conn.close() ;
                   catch (Exception e2)
         }

  • Problems implementing java.sql.ResultSet on AbstractTableModel

    Hi java Gurus !!
    I have a trouble implementing interface java.sql.ResultSet on javax.swing.table.AbstractTableModel. The AbstractTableModel class defines a method like
    this:
    int findColumn(String column)
    while the java.sql.Resultset defines a method as follows:
    int findColumn(String column) throws SQLException.
    the compiler gives me the following error:
    "Error #: 462 : method findColumn(java.lang.String) in class inducontrol.Untitled1 cannot override method findColumn(java.lang.String) in class javax.swing.table.AbstractTableModel, overridden method does not throw java.sql.SQLException at line 213, column 14
    How can I solve it?
    thanks a lot !!!!

    Hassen is correct, it seems that you mix two different things.
    Can you show code excerpts so we can give you some tips ?

  • Poblem with java.sql.Date while inserting to a table

    Hi All,
    I have a PostgreSQL database table which contains fields(columns ) of type date. I want to insert values to the table in the[b] �dd-MMM-YYYY� format using the prepared statement.
    My code is as follows
    java.text.DateFormat dateFormatter =new java.text.SimpleDateFormat("dd-MMM-yyyy");
    String formatedDate=dateFormatter.format(theDate);
    currentDate = new java.sql.Date(dateFormatter.parse(formatedDate).getTime())
    �������������������
    �������������������
    �������������������
    pst.setDate(12,currentDate);The problem is the currentDate variable gives date only in the �YYYY-MMM-dd� format but requirement is the currentDate variable should give date in the �dd-MMM-YYYY� format and this should be save to table as java.sql.Date type
    There is any solution???? please help me...
    Thanks and Regards,
    Hyson_05

    Hi,
    What are you talking about? A Date does always wrap a millisecond value, and doesn't have any formatting. It's the database, or your program which formats the date that you see.
    In short. You should format the value when you print it, and not when you store it.
    Kaj

Maybe you are looking for

  • Edi mapping for 856

    Hi,   can any one please map the below listed fields for edi 856..        Hierarchical Level 1)Hierarchical ID Number: 2)Hierarchical Parent ID Number: 3)Hierarchical Level Code: 4)Hierarchical Child Code:

  • How to create new subtypes for OM infotype 1002?

    Gurus,             I have a requirement to create four new subtypes (to different texts ) for OM infotype HRP1002. Let me know the procedure to achieve this. I looked in subtype table T591A and T591S, but couldn't find any subtype (even the standard

  • Help with WDScopeUtil in 2004s - Urgent please

    Hi, We are currently migrating our code from 2004 SP16 to 2004s. From the forum, I understood that we have to use WDScopeUtil in 2004s to pass data between pages and WDScopeUtil supports only Strings but We want to pass objects also. We came up with

  • Factory. recover. blue circle no stop

    I factory restored my Compaq Presario CQ61 now icant get the blue circle to stop. All sites wont come uo IE stops working shuts down What happen?

  • How to install AirPort Extreme 802.11n Enabler?

    I just bought the Airport Extreme and I have the CD that came with it loaded. I'm installing the package that is on the CD and it reads that the following items are available for installation and one of them is the Airport Extreme 802.11n Enabler. I