JAVA with MYSQL problem

i am using jdk1.6.0_02,apache tomcat 5.5.23 ,mysql integrated with redhat linux EE 4 and.mysql connector java 5.0.7.bin.jar.
look at the the following java program
import java.sql.*;
public class TestMysql
public static void main(String args[])
try
String driver = "com.mysql.jdbc.Driver";
Class.forName( driver );
String url = "jdbc:mysql://localhost/test";
DriverManager.getConnection( url, "root", "mysql" );
catch( Exception x )
{      x.printStackTrace();
i got the following exception
java.sql.SQLException: Access denied for user 'root'@'localhost.localdomain' (us *** password:
YES)
at com.mysql.jdbc.SQLError.createSQLException(java.lang.String, java.lang.Str ***, int)
(Unknown Source)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(int) (Unknown Source)
at com.mysql.jdbc.MysqlIO.checkErrorPacket() (Unknown Source)
at com.mysql.jdbc.MysqlIO.secureAuth411(com.mysql.jdbc.Buffer, int, java.lang .String,
java.lang.String, java.lang.String, boolean) (Unknown Source)
at com.mysql.jdbc.MysqlIO.doHandshake(java.lang.String, java.lang.String, jav a.lang.String)
(Unknown Source)
at com.mysql.jdbc.Connection.createNewIO(boolean) (Unknown Source)
at com.mysql.jdbc.Connection.Connection(java.lang.String, int, java.util.Prop erties,
java.lang.String, java.lang.String) (Unknown Source)
at com.mysql.jdbc.NonRegisteringDriver.connect(java.lang.String, java.util.Pr operties)
(Unknown Source)
at java.sql.DriverManager.getConnection(java.lang.String, java.util.Propertie s)
(/usr/lib/libgcj.so.5.0.0)
at java.sql.DriverManager.getConnection(java.lang.String, java.lang.String, j
ava.lang.String) (/usr/lib/libgcj.so.5.0.0)
at Connect.main(java.lang.String[]) (Unknown Source)
access denied problem. but the user name and password are correct. i can login to mysql by using
the same username and password.
but when connecting through java , i can't ? what is the problem?
can u help me.?
actually i am working in JSP. and when i got this problem, i created a small java program for testing.
here i am submitting the java program.

friend please put your code inside
   // your code goes here  it will more readable and other can solve it better.
==================
and your problem tells that you must set access permission inside
mySQL server.
or try with creating new User with password.
EnJOY.
Ghanshyam
Edited by: Ghanshyam on Sep 28, 2007 4:13 PM

Similar Messages

  • Date Problem in Java with MySql

    Hello
    I am using Java with Mysql.I want to enter date in some in my format(YYYY:MM:DD:HH:MM:SS), this thing i have convert using format class and format class return date in String and iwwnat to insert this value in MySQL Table,So i want to know how can i convert String value in Date for Mysql is their inbuild function for converting string into date in mysql.
    Regards
    Anupam S

    Use PreparedStatement and SimpleDateFormat classes
    http://onesearch.sun.com/search/onesearch/index.jsp?qt=%2BPreparedStatement+%2BSimpleDateFormat+&qp=siteforumid%3Ajava48&chooseCat=allJava&col=developer-forums&site=dev

  • Can' t connect Java with MySQL

    My goal is to connect Java with MySQL. I found many solutions on Internet, but I always get the same mistake:
    SQLException: No suitable driver
    SQLState: 08001
    VendorError: 0MySQL works fine alone or with php.Only thing left me to think is that the installed versions are not compatible for this mysql-connector-java-5.0.4
    I don't believe that could be a reason.
    Installed versions are:
    Apache Tomcat 5.5.20 Server
    Apache HTTP Server 2.2.4
    PHP 5.2.0
    MySQL 5.2
    jre 1.5.0_11
    jdk1.5.0_11
    Apache Tomacat JK2 connector Version: 1.2.20 File Name: mod_jk-apache-2.2.3.so
    mysql-connector-java-5.0.4
    I also set connector in class path: C:\mysql-connector-java-5.0.4;C:\mysql-connector-java-5.0.4\mysql-connector-java-5.0.4-bin.jar;C:\mysql-connector-java-5.0.4\src\com\mysql\jdbc
    For installation I used manulas from:
    http://apacheguide.org/jsp.php
    http://doc.51windows.net/mysql/?url=/MySQL/ch23s03.html
    Here is also a test code in java:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
       public class Connect
           public static void main (String[] args)
               Connection conn = null;
               try {
        conn =
           DriverManager.getConnection("jdbc:mysql://localhost/first_test" +
                                       "user=monty&password=greatsqldb");
        // Do something with the Connection
    } catch (SQLException ex) {
        // handle any errors
        System.out.println("SQLException: " + ex.getMessage());
        System.out.println("SQLState: " + ex.getSQLState());
        System.out.println("VendorError: " + ex.getErrorCode());
       }i'm desperate, please help or tell me someone who'll know the answer.
    Thank You in advance

    hey buddy .. it seems yr code is wrong .. in getconnection () method u should also specify the port ,which u r not doing ...
    the default port for MySQL is 3306 ... see below i am giving you a sample code ... its working fine .. and dont forget to put the MySQL driver jar path in to classpath and also copy the jar into common/lib folder of your tomcat ....
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class MySQLConnectionTest {
         public static void main(String[] args) {
    new MySQLConnectionTest().connTest();
    public void connTest() {
              String tableName = "portfolio"; //change as per setting
              String hostName = "10.81.9.39"; // please change for the target database ip or hostname
              String dbPort = "3306"; //change if not using the default
              String dbName = "tradingsystem"; //change as per the given DB name
              String username = "root"; //change as per setting
              String password = "password"; //change as per setting
              System.out.println("before try");
              Double data=0.0;
         Double data1=0.0;
              try {
    Class.forName("org.gjt.mm.mysql.Driver");
                   System.out.println("before driver manager");
    Connection conn = DriverManager.getConnection("jdbc:mysql://"+hostName+":"+dbPort+"/"+dbName, username, password);
    String query1 = "select * from "+tableName+" where User_id='trader1' and Stock_Type='Equity'";
    System.out.println("quesry1="+query1);
    Statement stmt = conn.createStatement();
    ResultSet rs1 = stmt.executeQuery(query1);
    while(rs1.next())
         System.out.println("hiiiiii for rs1");
         System.out.println(rs1);
         Quantity=(Integer)rs1.getObject(5);
         MarketPrice=(Double) rs1.getObject(8);
         data=Quantity*MarketPrice;
         data1+=data;
         System.out.println("data1="+data1);
         i=0;
    rs1.close();
    stmt.close();
    conn.close();
    } catch (ClassNotFoundException e) {
    e.printStackTrace(System.err);
    } catch (SQLException e) {
    e.printStackTrace(System.err);
    i hope it will work for u...
    cheers,

  • Problems conecting java with mysql

    Hi, im workin' with mysql-connector-java-3.1.12 and it work on debug runtime but not when i access the .jar of the project.
    the code of conection is:
    try
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    con = DriverManager.getConnection(url,login,password);
    con.setAutoCommit(false);
    catch (Exception e)
    JOptionPane.showMessageDialog(null,"error en " + e.getMessage());
    there is no problems with code, it works!!, but i don't know what to do about of conection in the .jar
    I apreciate some help with this, Thankkkssss!!!

    Hi, im workin' with mysql-connector-java-3.1.12 and
    it work on debug runtime but not when i access the
    .jar of the project.Huh?
    the code of conection is:
    try
    lass.forName("com.mysql.jdbc.Driver").newInstance();
    con =
    DriverManager.getConnection(url,login,password);
    con.setAutoCommit(false);This is probably wrong. Unnecessary in this case - you aren't doing any writes.
    catch (Exception e)
    OptionPane.showMessageDialog(null,"error en " +
    e.getMessage());This is foolish code. You don't need Swing or a dialog box. You're printing less information than is available. Better to print the entire stack trace.
    is no problems with code, it works!!, Plenty of problems, really, regardless of whether it "works".
    You don't post your URL. That would help.
    but i don't
    know what to do about of conection in the .jar
    I apreciate some help with this, Thankkkssss!!!Put in the CLASSPATH, of course. NOT a system environment variable, either. javac.exe and java.exe ignore it. Use the -classpath option.
    %

  • Java with MYSQL in Linux

    i am using JSP in Linux Platform. when i connected to mysql with mysql driver for odbc by using the following code,
    import java.sql.*;
    public class TestMysql
    public static void main(String args[]) {
    try {
              Connection con;
              String connStr = "jdbc:mysql://localhost/test?user=root&password=mysql";
              Class.forName( "com.mysql.jdbc.Driver" ).newInstance();
              System.out.println("OK");
              con = DriverManager.getConnection( connStr );
              System.out.println("Again OK");
    catch( Exception x )
    x.printStackTrace();
    i got the following exception
    OK
    java.sql.SQLException: Error during query: Unexpected Exception: java.io.CharConversionException message given: null
    Nested Stack Trace:
    ** BEGIN NESTED EXCEPTION **
    java.io.CharConversionException
    STACKTRACE:
    java.io.CharConversionException
    at gnu.gcj.convert.Input_iconv.read(char[], int, int) (/usr/lib/libgcj.so.5.0.0)
    at java.lang.String.init(byte[], int, int, java.lang.String) (/usr/lib/libgcj.so.5.0.0)
    at java.lang.String.String(byte[], int, int, java.lang.String) (/usr/lib/libgcj.so.5.0.0)
    at com.mysql.jdbc.SingleByteCharsetConverter.SingleByteCharsetConverter(java.lang.String) (Unknown Source)
    at com.mysql.jdbc.SingleByteCharsetConverter.initCharset(java.lang.String) (Unknown Source)
    at com.mysql.jdbc.SingleByteCharsetConverter.getInstance(java.lang.String, com.mysql.jdbc.Connection) (Unknown Source)
    at com.mysql.jdbc.Connection.getCharsetConverter(java.lang.String) (Unknown Source)
    at com.mysql.jdbc.StringUtils.getBytes(java.lang.String, java.lang.String, java.lang.String, boolean, com.mysql.jdbc.Connection) (Unknown Source)
    at com.mysql.jdbc.Buffer.writeStringNoNull(java.lang.String, java.lang.String, java.lang.String, boolean, com.mysql.jdbc.Connection) (Unknown Source)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(com.mysql.jdbc.Statement, java.lang.String, java.lang.String, com.mysql.jdbc.Buffer, int, com.mysql.jdbc.Connection, int, int, boolean, java.lang.String, boolean) (Unknown Source)
    at com.mysql.jdbc.Connection.execSQL(com.mysql.jdbc.Statement, java.lang.String, int, com.mysql.jdbc.Buffer, int, int, boolean, java.lang.String, boolean, boolean) (Unknown Source)
    at com.mysql.jdbc.Connection.configureClientCharacterSet() (Unknown Source)
    at com.mysql.jdbc.Connection.initializePropsFromServer() (Unknown Source)
    at com.mysql.jdbc.Connection.createNewIO(boolean) (Unknown Source)
    at com.mysql.jdbc.Connection.Connection(java.lang.String, int, java.util.Properties, java.lang.String, java.lang.String) (Unknown Source)
    at com.mysql.jdbc.NonRegisteringDriver.connect(java.lang.String, java.util.Properties) (Unknown Source)
    at java.sql.DriverManager.getConnection(java.lang.String, java.util.Properties) (/usr/lib/libgcj.so.5.0.0)
    at java.sql.DriverManager.getConnection(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
    at TestMysql.main(java.lang.String[]) (Unknown Source)
    ** END NESTED EXCEPTION **
    at com.mysql.jdbc.Connection.execSQL(com.mysql.jdbc.Statement, java.lang.String, int, com.mysql.jdbc.Buffer, int, int, boolean, java.lang.String, boolean, boolean) (Unknown Source)
    at com.mysql.jdbc.Connection.configureClientCharacterSet() (Unknown Source)
    at com.mysql.jdbc.Connection.initializePropsFromServer() (Unknown Source)
    at com.mysql.jdbc.Connection.createNewIO(boolean) (Unknown Source)
    at com.mysql.jdbc.Connection.Connection(java.lang.String, int, java.util.Properties, java.lang.String, java.lang.String) (Unknown Source)
    at com.mysql.jdbc.NonRegisteringDriver.connect(java.lang.String, java.util.Properties) (Unknown Source)
    at java.sql.DriverManager.getConnection(java.lang.String, java.util.Properties) (/usr/lib/libgcj.so.5.0.0)
    at java.sql.DriverManager.getConnection(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
    at TestMysql.main(java.lang.String[]) (Unknown Source)
    i have the database, hello.
    The same code works well in Windows, But in Linux, the above exception.
    By using the username root and password mysql , i can connect to mysql directly from the mysql prompt.
    Pls help me..
    I have already put the query 'access denied problem in Mysql' some day before. from the reply, i made some changes in user table(ie. set the password for [email protected].).After this change, this new Exception came..
    The structure of my mysql.user table is
    #     host                         user          password
    1     localhost                    root          68d4f47c49a579c9
    2     localhost.localdomain          root          68d4f47c49a579c9
    3     localhost.localdomain          
    4     localhost          
    Pls help me.
    Edited by: SUMESHBABU_R on Sep 30, 2007 11:36 PM

    Well, at least the trace tells me that this issue is to be tracked back to the core of the MySQL JDBC driver and the Linux's implementation of JVM. It might be worth the effort to post this issue at their website/forum/issuetracker. It might also be worth the effort to tryout the newer MySQL JDBC driver 5.1, as it is written specific for JDK 6.0 (while MySQL JDBC driver 5.0 is targeted at JDK 5.0).

  • Hoe to connect java with mysql 5.0

    I have installed the new Os. in that RHE-5 Os is there, now I want that java can connect ot mysql but , its not able connect with mysql so please guide me.

    1) download mysql connector/J JDBC driver from mysql.com
    2) put the driver jar somewhere where you can put it in the classpath of your application
    3) use proper setup code to connect to the database (search google, tons of examples)
    If at any step you have no clue what I am talking about, you need a good book to help you further.

  • Connectivity java with mySql

    Hi
    Can any one tell me how should i connect my java application with mySql database here is the small code which i written.
    import java.sql.*;
    class tryjdbc
         public static void main(String[] args) throws Exception
         try
              Class.forName("com.mysql.jdbc.Driver").newInstance();
              String connectionURL = "jdbc:mysql://localhost:3306/learn?user=root;password=";
              Connection connection = DriverManager.getConnection(connectionURL, "root", "");
              Statement statement = connection.createStatement();
              ResultSet rs = statement.executeQuery("Select ecode from emp");
              while (rs.next())
                   System.out.println(rs.getString("ecode"));
              catch (Exception e){
                   System.out.println(e);
    Can any one please tell me the error there is no eror in compiling but at run time it gives error
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    Thanks in advance
    Dhiraj

    Hi Dhiraj,
    String connectionURL = "jdbc:mysql://localhost:3306/learn?user=root;password=";
    Connection connection = DriverManager.getConnection(connectionURL, "root", "");
    It seems to be your trying to pass twice of your properties details. One from through URL and another from by pasing the parameters on getConnection() method. Better to avoid to use two place in same application. and one more thing I want to confirm r u using "stable" Driver or "alpha" Driver.
    Raju

  • Building postfix with mysql problem

    Hi all,
    I have a sun fire v880 machine running solaris 10, i need to set an email server using postfix+mysql.
    I already installed myql and its working fine. but when trying to build postfix with mysql i get a compliation error, here's wts going on:
    bash-3.00# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/bdb/include -I/opt/mysql/mysql/include -DUSE_SASL_AUTH' 'AUXLIBS=-L/opt/mysql/mysql/lib -R/opt/mysql/mysql/lib -lmysqlclient -lz -lm'
    (echo "# Do not edit -- this file documents how Postfix was built for your machine."; /bin/sh makedefs) >makedefs.tmp
    set +e; if cmp makedefs.tmp conf/makedefs.out; then rm makedefs.tmp; \
    else mv makedefs.tmp conf/makedefs.out; fi >/dev/null 2>/dev/null
    set -e; for i in src/util src/global src/dns src/tls src/xsasl src/milter src/master src/postfix src/smtpstone src/sendmail src/error src/pickup src/cleanup src/smtpd src/local src/trivial-rewrite src/qmgr src/oqmgr src/smtp src/bounce src/pipe src/showq src/postalias src/postcat src/postconf src/postdrop src/postkick src/postlock src/postlog src/postmap src/postqueue src/postsuper src/qmqpd src/spawn src/flush src/verify src/virtual src/proxymap src/anvil src/scache src/discard src/tlsmgr; do \
    (set -e; echo "[$i]"; cd $i; rm -f Makefile; \
    make -f Makefile.in Makefile MAKELEVEL=) || exit 1; \
    done;
    [src/util]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/global]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/dns]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/tls]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/xsasl]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/milter]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/master]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/postfix]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/smtpstone]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/sendmail]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/error]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/pickup]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/cleanup]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/smtpd]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/local]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/trivial-rewrite]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/qmgr]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/oqmgr]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/smtp]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/bounce]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/pipe]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/showq]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/postalias]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/postcat]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/postconf]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/postdrop]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/postkick]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/postlock]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/postlog]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/postmap]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/postqueue]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/postsuper]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/qmqpd]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/spawn]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/flush]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/verify]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/virtual]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/proxymap]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/anvil]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/scache]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/discard]
    (cat ../../conf/makedefs.out Makefile.in) >Makefile
    [src/tlsmgr]
    (set -e; echo "# DO NOT EDIT"; /bin/sh ../../makedefs && cat Makefile.in) >Makefile
    rm -f Makefile; (cat conf/makedefs.out Makefile.in) >Makefile
    * Then when i run:
    bash-3.00# /usr/local/bin/make
    The compilation goes on till i get the following error
    "ld: warning: file /opt/mysql/mysql/lib/libmysqlclient.a(libmysql.o): wrong ELF class: ELFCLASS64
    Undefined first referenced
    symbol in file
    mysql_fetch_row ../../lib/libglobal.a(dict_mysql.o)
    mysql_query ../../lib/libglobal.a(dict_mysql.o)
    mysql_error ../../lib/libglobal.a(dict_mysql.o)
    mysql_close ../../lib/libglobal.a(dict_mysql.o)
    mysql_free_result ../../lib/libglobal.a(dict_mysql.o)
    mysql_store_result ../../lib/libglobal.a(dict_mysql.o)
    mysql_init ../../lib/libglobal.a(dict_mysql.o)
    mysql_real_connect ../../lib/libglobal.a(dict_mysql.o)
    mysql_real_escape_string ../../lib/libglobal.a(dict_mysql.o)
    mysql_num_rows ../../lib/libglobal.a(dict_mysql.o)
    mysql_num_fields ../../lib/libglobal.a(dict_mysql.o)
    mysql_escape_string ../../lib/libglobal.a(dict_mysql.o)
    ld: fatal: Symbol referencing errors. No output written to error
    collect2: ld returned 1 exit status
    make: *** [error] Error 1
    make: *** [update] Error 1"
    Please help me with this issue, i use gcc-3.3.2 and used both GNU make and the "make" shipped with solaris, both gave the same result.
    I installed Mysql as a pkg and didn't compile it from source.
    Thanks in advance.

    "ld: warning: file /opt/mysql/mysql/lib/libmysqlclient.a(libmysql.o): wrong ELF class: ELFCLASS64Usually this kind of error is an indication that both 32- and 64-bit object files are being used in building the application. Use all 32-bit objects or 64-bit objects - please do not mix them during compilation.
    If building from scratch is not mandatory for you, you can try installing postfix {and other applications, libraries, ..} with the help of Blastwave's 'pkg-get'. Some instrustions are at: http://technopark02.blogspot.com/2005/06/solaris-installing-appspackages-with.html
    % pkg-get -a | grep postfix
                 postfix 2.2.8,REV=2006.03.13

  • EJB 3.0 entity beans generation with MySql - problem

    Hi,
    I am using JDev 10.1.3 Production and using the EJB3.0 CMP wizard to generate the code from a MySQL database. No matter what type I specify for my database columns in schema, code generator always generates the properties of type String only. e.g if a column called Age is specified as Integer in schema, the generator generates setters/getters with String type.
    Can somebody please help me.
    Regards
    Vimal

    Hi,
    I'm experiencing same problems, is this a bug or an feature?

  • How make installer java with mySQL database

    How do I create a java installer for windows, because I have a project that uses mySQL database.
    Anyone please help me....

    If you have eg. a desktop application which needs a database, but don't have/ need a database server, which is accessed by several instances of the application (which seems to be the case, otherwise you wouldn't want to install it along with the application), consider an embedded database such as Apache Derby/ Java DB.
    Then all you need is to ship some jars and make sure they are on the classpath.
    If you're using JPA and generate the DB schema, then switching DB vendors should be quite easy. Just reconfigure your persistence.xml.

  • Java with mysql

    if two tables r given, i want a code which should tell tat ,in which table foreign key is available.
    so please kindly help out in this problem.
    is there is any query or code avalible to find out which table as foreign key.

    I don't know if this will have what you're looking for, but that kind of information is available with [url http://java.sun.com/j2se/1.5.0/docs/api/java/sql/DatabaseMetaData.html]DatabaseMetaData. You get it with [url http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Connection.html#getMetaData()]Connection.getMetaData().
    If you're not familiar with JDBC, see this tutorial:
    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/

  • Applescript with mysql problem (An error of type 1 has occured)

    Hi all!
    I'm quite new to scripting with applescript...
    Currently I'm trying to get applescript to connect to a remote mysql-database, and execute a insert-command.
    All is working fine, when I just use a select-command.
    But when I try to use my insert-query, I get this error:
    "An error of type 1 has occured".
    I've googled high and low, but cant seem to find out either if this is mysql returning the error-code or if it's applescript returning it.
    set mySQLList to {"/usr/local/mysql-5.1.30-osx10.5-x86/bin/", "/Library/mysql-5.1.30-osx10.5-x86/bin"}
    repeat with i from 1 to the count of mySQLList
         try
              set theResult to do shell script (item i of mySQLList) & "mysql -V"
              set gPathToMySQL to (item i of mySQLList)
              set haveFound to true
              exit repeat
         end try
    end repeat
    set gmySQLCommand to gPathToMySQL & "mysql"
    set theHost to "server"
    set theUser to "username"
    set thePassword to "password"
    set thePort to "3306"
    set theDatabase to "database"
    set theTable to "recivedMail"
    set theLoginString to " -h " & theHost & " -u " & theUser & "  --password=" & thePassword
    set dataBaseString to " -D " & "'" & theDatabase & "'"
    --set theCommand to gmySQLCommand & theLoginString & dataBaseString & " -e \"" & "select count(*) from recivedMail;" & "\""
    set theCommand to gmySQLCommand & theLoginString & dataBaseString & " -e \"" & "INSERT INTO database.recivedMail (sentTo,ticket,dateRecived) VALUES ('[email protected]', 'en ticket', '2009-01-21 17:15:56'); " & "\""
    -- set theCommand to gmySQLCommand & theLoginString & dataBaseString & " -e \"" & "SELECT COUNT(*) FROM recivedMail;" & "\""
    set theResult to ""
    --display dialog theCommand
    try
         set theResult to do shell script theCommand
    on error errMsg
         display dialog errMsg
    end try
    return theResult
    can someone here help me out?

    I just had the same problem you described below. I did some searching on the subject in the forums and there seems to be an issue with A.Pack on dual processor machines. I kept getting errors until I shut one of the processors off. The encoding went thru on the first attempt after that.
    There is a system preference pane called Processor that will allow you to shut off one of the processors. Then launch A.Pack and encode. I believe this preference pane is installed when you install the developer software with xcode. The developer software can be found on the Tiger install disc.
    Also, they have done away with A.Pack and this issue in DVDSP 4. Apparently A.Pack is integrated somehow into Compressor.
    Hope this helps. Good luck.
    Dual 1.25GHz   Mac OS X (10.4.3)   1.25GB Ram 22" Cinema & 17" Acer

  • Need help on java with mysql...

    I want to make application that will use mysql as database. I have downloaded mysql connector j but i'm confuse about how to install it to jdk. for reference, i'm using windows xp, phptriad that have mysql 4.1.
    After that, how do I connect my application to the database?
    please help...
    Thanks before...

    Have a look at this tutorial:
    http://java.sun.com/docs/books/tutorial/jdbc/index.html

  • Using java with mysql JDBC

    Hello
    I'm trying to write a program which reads in tab-delimeted text files and then stores the results in a mysql database. The files are roughly 20,000 lines long and can have up to 10 columns, so for the biggest files I have 200,000 pieces of data to be stored seperately in the database.
    I'm currently using the readLine() method of bufferedreader, then using the split function to seperate the string into tokens. The problem is that it seems to be very slow. It is a lot of information, and im not running it on a very fast machine, but even so im sure there must be a more efficient way of acheiving this.
    Here's some of my code:
    BufferedReader in = new BufferedReader(new FileReader("test.res"));
    while((result = in.readLine()) != null) {
    result = in.readLine();
    aLine = result.split("\t");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[0] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[1] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[2] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[3] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[4] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[5] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[6] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[7] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[8] +"')");
    stmt.executeUpdate("INSERT INTO test(words)" + "values('" + aLine[9] +"')");
    I would appreciate any advice thanks.
    PS this is the first time ive tried anything like this so im probably missing something obvious.

    Form the example you have chosen it seems to me, that your table only has one column (words) and that you have multiple value entries for that column in one line of your text file ?!
    That is strange. Normaly I would assume (like the other answers indicate) that you have several columns and that each line in your text file has n values each for a different column.
    Have look at PreparedStatement.
    // the name of your connection is con, you have six columns named col1 to col6 and six entries per line, All six are strings...
    PreparedStatement pstmt = con.prepareStatement("insert into test (col1 , col2 , col3,col4,col5,col6) values( ? , ? , ? , ? , ? , ?)") ;
    BufferedReader in = new BufferedReader(new FileReader("test.res"));
    while((result = in.readLine()) != null) {
       result = in.readLine();
       aLine = result.split("\t");
       for (int i = 0 ; i < 6 ; i++) {
           pstmt.setString((i+1),aLine) ;
    pstmt.executeUpdate() ;
    But this is still not the fastest approach. MySQL supports bulk imports
    Have look at this feature. Maybe the fastest way is to 'convert' the textfile into something like a MySQL dump an than process it using it the MySQL import features.

  • Toplink with mysql: problem with blob size

    I'm using toplink with a mysql database. I want to store some data in a blob.
    In mysql there exist different sizes of blobs (in my case I need a mediumblob).
    But if I create the scheme for the database with jpa/toplink it alway creates only a column with type blob.
    I can explicitly tell the database to use a mediumblob by this:
    @Column("MEDIUMBLOB")
    But by doing this I limit my program to mysql of course, as this data type is not known to other databases.
    Does anybody know a more elegant solution to setting the blob size?
    for example with hibernate it can be done this way:
    @Column(length=666666)

    Looks like you are using JPA, and in JPA you would set the columnDefinition to the type that you want, e.g.
    @Lob
    @Column(name="BLOBCOL", columnDefinition="MEDIUMBLOB")
    byte[] myByteData;
    As you mentioned, this does introduce a dependency on the database. However, you can always either put the Column metadata in XML, or override it with something else later in XML.
    The length attribute was intended and specified for use with Strings but I guess there is no reason why it couldn't be used for BLOBs as well (please enter an enhancement request, or submit the code to add the feature to EclipseLink). Be aware, though, that doing so at this stage is going to be introducing a dependency on the provider to support a non-spec defined feature.

Maybe you are looking for

  • How to connect my mini-dv camcorder to new imac with no firewire

    I have a Sony Mini-DV camcorder (Handycam) and used to connect it via firewire to my last iMac. My new iMac doesn't have firewire - just thunderbolt & usb. Is there a way I can use this camcorder on my new iMac? Are there adaptors, etc.? Thanks.

  • Set up account for mail

    Hello, I have a new ipowerbook and it is my first mac. I love it and I am already familiar with with the other features, BUT today I wanted to setup "mail". It is writing me "The .Mac server "mail.mac.com" rejected the password..." Where can I setup

  • ADF Data Binding : Iteration in child records.

    I have the following situation and I cannot find a solution : I have two view objects, StudentList and CourseList. I have also a View Link "StudentsInCourse", connecting "StudentList" and "CourseList" with cardinality M:N. This connection is exposed

  • Open Powerpoint file in Safari on Mac OS X (as in iOS)

    In iOS (iPad/iPhone), i can open hyperlinked Powerpoint files (.ppt) in a new tab in Safari. Is it possible to imitate this behavior in Mac OS X?

  • Using an external css in Flex 4

    I'm using the Flex 4 beta and the ability to load an external css seems to be broken. Running the code below shows no styling at all. Have I missed something? components.MainPanel.as: package components { import flash.events.Event; import flash.net.U