J2ME with ODBC/mySQL/JDBC
hi all,
is there anyway to make a connection to a MSAccess file?
then from there, getting info from it and returning the inputs to the file?
above queries are for usage on J2ME.
T.N. J2ME has a language limited to javax.microedition.*
regards and thanks in advance,
Nicky
Have you tried using a JDBC-ODBC bridge driver??i'm a newbie to J2ME,.. and everything else except basic java.
can u kindly explain and guide me thru it?
one more thing is, can it work with J2ME??
Nicky.
Similar Messages
-
No suitable driver with com.mysql.jdbc.Driver
Ok. here's the issue. I have a windows box. (first problem) but let's pretend that it's ok. :) I installed Tomcat 4.1 installed J2SDK1.4.0
start serving pages GREAT!. I have Mysql working perfectly with PHP on this system. I JUST want to connect with JDBC :)
I've downloaded the MySQL Jdbc Connector/J 3.08 stable installed the .jar file in the $JAVA_HOME/jre/lib/ext as per the README
Now granted I am a little new to JSP. but I have checked over this again and again. used different code. connected as many ways as I can think of and I still get the same result.
Database Error :
No suitable driver
Please Try Some Other Time
So I figure it's a MYSQL issue. no I also went thru and did the Microsot connection to MS SQL 2000 with the same result.
Here's where the drivers are (tried using the other method for installing the MySQL connector as well, and my class path
Y:\j2sdk1.4.0\com\mysql\jdbc\Driver.class
com.mysql.jdbc.Driver.class
Y:\j2sdk1.4.0\org\gjt\mm\mysql\Driver.class
org.gjt.mm.mysql.Driver.class
My classpath is:
.;F:\j2sdk1.4.0\;F:\j2sdk1.4.0\bin\;F:\j2sdk1.4.0\lib\;F:\j2sdk1.4.0\lib\classes\
[ Here's The Enviorment]
Windows 2000 5.00.2195 SP3
MS SQL 2K SP3
Apache Tomcat/4.1.27
j2sdk1.4.0
MySql 3.23.57-nt
mysql Jdbc Connector/J 3.08 stable
<!-- mysql.jsp BEGIN-->
<%@ page import="java.sql.*" %>
<%
Connection conn;
ResultSet results;
try {
String jdbc_driver = "com.mysql.jdbc.Driver";
System.out.println("jdbc_driver = " + jdbc_driver);
Class.forName(jdbc_driver).newInstance();
catch (ClassNotFoundException cnfe)
System.out.println(cnfe.getMessage());
try {
String url = "jdbc:mysql://localhost:3306/javatest?username=root,password=****"; // pass hidden
conn = DriverManager.getConnection(url);
System.out.println("connected to mySql DataBase");
Statement stmt = conn.createStatement();
Statement smt=conn.createStatement();
results=smt.executeQuery("select * from testdata");
while(results.next())
%>
<%= results.getString("foo")%>
<%= results.getString("bar")%>
<%= results.getString("id")%>
<%
results.close();
conn.close();
catch(Exception exp)
%>
<H3>Database Error : </H3><B><%= exp.getMessage() %></B><H3>Please Try Some Other Time</H3>
<%
%>
<!-- mysql.jsp end -->
BTW i aslo tried connecting to MicrosoftSQL 2K
<!-- microsoft.jsp Begin -->
<%@ page import="java.sql.*" %>
<%
Connection conn;
ResultSet results;
try {
String jdbc_driver = "sun.jdbc.odbc.JdbcObdcDriver";
System.out.println("jdbc_driver = " + jdbc_driver);
Class.forName(jdbc_driver).newInstance();
catch (ClassNotFoundException cnfe)
System.out.println(cnfe.getMessage());
try {
String url = "jdbc:odbc:contacts";
String username = "javauser";
String pw = "javauser";
conn = DriverManager.getConnection(url, username, pw);
System.out.println("connected to Msoft DataBase");
Statement stmt = conn.createStatement();
Statement smt=conn.createStatement();
results=smt.executeQuery("select * from contacts");
while(results.next())
%>
<%= results.getString("name")%><br>
<%
results.close();
conn.close();
catch(Exception exp)
%>
<H3>Database Error : </H3><B><%= exp.getMessage() %></B><H3>Please Try Some Other Time</H3>
<%
%>
<!-- microsoft.jsp end -->
got the exact same results.
Just to show you mysql is Good. with localhost.
mysql -u root -h localhost -p
mysql> use javatest
Database changed
mysql> select * from testdata;
| id | foo | bar |
| 1 | hello | 12345 |
1 row in set (0.00 sec)
mysql>Nope, it's not a MySQL issue.
I'd recommend NOT putting the JDBC JAR file (or any others, except Sun-sanctioned extensions) in JAVA_HOME/jre/lib/ext.
JDBC JARs belong in TOMCAT_HOME/common/lib or in the WEB-INF/lib directory for your particular app. If you put them in the former, all apps running under Tomcat can have access to them. If you put them in the latter, only your app can see them.
After you've done that, do some reading about JNDI data sources under Tomcat:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
That way you can get that connection code out of your JSPs and into the web.xml and <Context>, where it belongs. You'll be able to change data sources without rewriting your pages.
Good luck - MOD -
Help with com.mysql.jdbc.Driver
Hi all
I am new to working with java. I am working off of my laptop (pc -vista) and
am trying to connect to a database on a server I have, mac osx 10.x.
First question: I would install com.mysql.jdbc.Driver on the same server as
the MySql server correct?
Second and more important question: I have multiple pages
printed out on installing this driver but I just cannot follow it. I am not
very good in terminal(mac) and the install seems terminal based.
Can someone please try to explain to me in laymen terms what needs to
be done?
thanks alot
Marcusmarcusam wrote:
sorry for my lack of knowledge
client code = all on one machine?No, client code = the code you use to access your DB server.
>
I wanted to access a database that was on a totally different machine, with a java application.
is this not very doable - or realistic?
It's completely doable.
i found enviroment variables for CLASSPATH that are pointing inside 'jre1.6.0_07'
but i also have 'jdk1.6.0_07' - should the development kit be the one i use? - sorry
back to original question - so would i just move the .jar file into
\jre1.6.0_02\lib\ext\ or something of that sort
thanks alot
MarcusYes, you can move the jar into the ext directory if you wish. How are you running your java application? What are you typing/clicking on? -
Crystal Reports 2008, mySQL, JDBC, and ODBC
Hello everyone.
I have just spent a very challenging few days getting Crystal Reports 2008 Developer (advanced version) working with a mySQL data source. I fell into several pits and narrowly escaped being eaten by monsters. I thought I'd share my experience to spare others the same trouble. All the stuff I'm writing about here applies to the runtime as well as the Developer UI.
I'm working on Windows Server 2008 R2, 64 bit, standard edition. The mySQL server is 5.1.42. The mySQL ODBC connector is version 5.1.6. You need the 32-bit version of this connector, even if you're on a 64-bit machine.
Lessons learned:
1. JDBC connectivity in Crystal Reports doesn't work correctly. It consumes excessive memory when a report requires lots of rows from a data base. Don't even think about using it.
2. Crystal Reports has a problem with ODBC for mySQL in which it sometimes gives a dialog box with these words in it.
The alias requested 'SOME_TABLE_NAME', contains a combination
of characters which is not considered to be valid.
This error message come up when using items on Crystal's "Database" menu like "Set Datasource Location..."
To fix this you need to make a registry change. As far as I know this has to be done for each account on each machine running the Crystal Developer. (insert usual warning about registry editor). Find the key named:
[HKEY_CURRENT_USER\Software\Business Objects\Suite 12.0\Crystal Reports\Database
Create a new string value named InvalidAliasCharList Give it this value:
.:{}()@&$#^!*~|%\\\"
Notice that the last two characters are backslash double-quote.
Good luck. It actually works pretty well now that it's working.
If any other community member can offer corrections or better ways of coping with this stuff, please do!Good morning,
I was wondering if I may ask some additional help...
We're on version 14.0.4.738 RTM and we are having the same issue.... need to enter the alias as table name with a backslash, ie serparate_work_orders\ for login credential reasons, but all the regedits listed seem to refer to locations in the registry that dont exist.
Version 14 have two "database locations" from what i can see called...
HKEY_CURRENT_USER\Software\SAP BusinessObjects\Suite XI 4.0\Crystal Reports\DatabaseOptions
and
HKEY_CURRENT_USER\Software\SAP BusinessObjects\Suite XI 4.0\Crystal Reports\DatabaseServer
I've applied the patch to both these locations and still no joy, same error message!
Any ideas? -
Com.mysql.jdbc.driver and jdbc:odbc bridge driver
Hi All,
I want to update mysql database from data in hashtable. My application already uses JDBC:OBDC bridge driver for retrieving data from excel sheet and putting in hashtable.
For connecting to mysql i need to use com.mysql.jdbc.driver too in the same code.
How to do that?
my code uses.
Read(String strFilePath,String strFileName)
filepath = strFilePath;
filename = strFileName;
strDriver= "jdbc:odbc:Driver={MicroSoft Excel Driver (*.xls)}";ThanksPlease stay with one thread:
http://forum.java.sun.com/thread.jspa?threadID=5145466&tstart=0
Please don't cross-post this way. -
Hi all,
I got this error when I tried to execute a simple JSF app. I am using JDeveloper 10.1.3 release edition. Please advice
[Starting OC4J using the following ports: HTTP=8988, RMI=23891, JMS=9227.]
**** Unable to obtain password from principals.xml. Using default.
C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\config>
C:\JDeveloper10g\jdk\bin\javaw.exe -ojvm -classpath C:\JDeveloper10g\j2ee\home\oc4j.jar;C:\JDeveloper10g\jdev\lib\jdev-oc4j-embedded.jar -Xverify:none -DcheckForUpdates=adminClientOnly -Doracle.application.environment=development -Doracle.j2ee.dont.use.memory.archive=true -Doracle.j2ee.http.socket.timeout=500 -Doc4j.jms.usePersistenceLockFiles=false oracle.oc4j.loader.boot.BootStrap -config C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\config\server.xml
[waiting for the server to complete its initialization...]
2006-01-31 21:40:47.062 NOTIFICATION Auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\dms.war...
2006-01-31 21:40:47.093 NOTIFICATION Unjar C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\dms.war in C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\dms
2006-01-31 21:40:47.093 NOTIFICATION Finished auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\dms.war
2006-01-31 21:40:47.156 NOTIFICATION Auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\connectors\datasources\datasources.rar...
2006-01-31 21:40:47.156 NOTIFICATION Unjar C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\connectors\datasources\datasources.rar in C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\connectors\datasources\datasources
2006-01-31 21:40:47.171 NOTIFICATION Finished auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\connectors\datasources\datasources.rar
2006-01-31 21:40:47.218 NOTIFICATION Auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j.ear...
2006-01-31 21:40:47.281 NOTIFICATION Unjar C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j.ear in C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j
2006-01-31 21:40:47.359 NOTIFICATION Finished auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j.ear
2006-01-31 21:40:47.375 NOTIFICATION Auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j\webapp.war...
2006-01-31 21:40:47.375 NOTIFICATION Unjar C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j\webapp.war in C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j\webapp
2006-01-31 21:40:59.296 NOTIFICATION Finished auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j\webapp.war
2006-01-31 21:41:08.421 WARNING J2EE OJR0107 Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
06/01/31 21:41:08 SEVERE: ApplicationStateRunning.initConnector Error occurred initializing connectors. Exception is: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
Jan 31, 2006 9:41:08 PM com.evermind.server.ApplicationStateRunning initConnector
SEVERE: Error occurred initializing connectors. Exception is: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
06/01/31 21:41:08 SEVERE: ApplicationStateRunning.initConnector Stack trace: oracle.oc4j.sql.DataSourceException: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
at com.evermind.server.ApplicationStateRunning.initDataSourceConnectionPool(ApplicationStateRunning.java:2016)
at com.evermind.server.ApplicationStateRunning.initDataSourceConnector(ApplicationStateRunning.java:1961)
at com.evermind.server.ApplicationStateRunning.initConnector(ApplicationStateRunning.java:1220)
at com.evermind.server.ApplicationStateRunning.initConnectors(ApplicationStateRunning.java:356)
at com.evermind.server.ApplicationStateRunning.initializeApplication(ApplicationStateRunning.java:208)
at com.evermind.server.Application.setConfig(Application.java:391)
at com.evermind.server.Application.setConfig(Application.java:309)
at com.evermind.server.ApplicationServer.addApplication(ApplicationServer.java:1771)
at com.evermind.server.ApplicationServer.initializeDeployedApplications(ApplicationServer.java:1532)
at com.evermind.server.ApplicationServer.setConfig(ApplicationServer.java:939)
at com.evermind.server.ApplicationServerLauncher.run(ApplicationServerLauncher.java:113)
at java.lang.Thread.run(Thread.java:595)
Caused by: javax.resource.ResourceException: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
at oracle.oc4j.sql.spi.ResourceAdapterImpl.createDataSourceConnectionPool(ResourceAdapterImpl.java:106)
at oracle.oc4j.sql.DataSourceUtils.getDataSourceConnectionPool(DataSourceUtils.java:322)
at com.evermind.server.ApplicationStateRunning.initDataSourceConnectionPool(ApplicationStateRunning.java:1997)
... 11 more
Caused by: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
at oracle.oc4j.sql.config.DataSourceConfigUtils.createConnectionFactory(DataSourceConfigUtils.java:247)
at oracle.oc4j.sql.DataSourceConnectionPoolImpl.<init>(DataSourceConnectionPoolImpl.java:107)
at oracle.oc4j.sql.spi.ResourceAdapterImpl.createDataSourceConnectionPool(ResourceAdapterImpl.java:99)
... 13 more
Caused by: oracle.classloader.util.AnnotatedClassNotFoundException:
Missing class: com.mysql.jdbc.Driver
Dependent class: oracle.oc4j.sql.config.DataSourceConfigUtils
Loader: oc4j:10.1.3
Code-Source: /C:/JDeveloper10g/j2ee/home/lib/oc4j-internal.jar
Configuration: <code-source> in META-INF/boot.xml in C:\JDeveloper10g\j2ee\home\oc4j.jar
This load was initiated at current-workspace-app.root:0.0.0 using the Class.forName() method.
The missing class is not available from any code-source or loader in the system.
at oracle.classloader.PolicyClassLoader.handleClassNotFound(PolicyClassLoader.java:2061)
at oracle.classloader.PolicyClassLoader.internalLoadClass(PolicyClassLoader.java:1665)
at oracle.classloader.PolicyClassLoader.loadClass(PolicyClassLoader.java:1621)
at oracle.classloader.PolicyClassLoader.loadClass(PolicyClassLoader.java:1606)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at oracle.oc4j.sql.config.DataSourceConfigUtils.createConnectionFactory(DataSourceConfigUtils.java:244)
... 15 more
Jan 31, 2006 9:41:08 PM com.evermind.server.ApplicationStateRunning initConnector
SEVERE: Stack trace: oracle.oc4j.sql.DataSourceException: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
at com.evermind.server.ApplicationStateRunning.initDataSourceConnectionPool(ApplicationStateRunning.java:2016)
at com.evermind.server.ApplicationStateRunning.initDataSourceConnector(ApplicationStateRunning.java:1961)
at com.evermind.server.ApplicationStateRunning.initConnector(ApplicationStateRunning.java:1220)
at com.evermind.server.ApplicationStateRunning.initConnectors(ApplicationStateRunning.java:356)
at com.evermind.server.ApplicationStateRunning.initializeApplication(ApplicationStateRunning.java:208)
at com.evermind.server.Application.setConfig(Application.java:391)
at com.evermind.server.Application.setConfig(Application.java:309)
at com.evermind.server.ApplicationServer.addApplication(ApplicationServer.java:1771)
at com.evermind.server.ApplicationServer.initializeDeployedApplications(ApplicationServer.java:1532)
at com.evermind.server.ApplicationServer.setConfig(ApplicationServer.java:939)
at com.evermind.server.ApplicationServerLauncher.run(ApplicationServerLauncher.java:113)
at java.lang.Thread.run(Thread.java:595)
Caused by: javax.resource.ResourceException: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
at oracle.oc4j.sql.spi.ResourceAdapterImpl.createDataSourceConnectionPool(ResourceAdapterImpl.java:106)
at oracle.oc4j.sql.DataSourceUtils.getDataSourceConnectionPool(DataSourceUtils.java:322)
at com.evermind.server.ApplicationStateRunning.initDataSourceConnectionPool(ApplicationStateRunning.java:1997)
... 11 more
Caused by: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
at oracle.oc4j.sql.config.DataSourceConfigUtils.createConnectionFactory(DataSourceConfigUtils.java:247)
at oracle.oc4j.sql.DataSourceConnectionPoolImpl.<init>(DataSourceConnectionPoolImpl.java:107)
at oracle.oc4j.sql.spi.ResourceAdapterImpl.createDataSourceConnectionPool(ResourceAdapterImpl.java:99)
... 13 more
Caused by: oracle.classloader.util.AnnotatedClassNotFoundException:
Missing class: com.mysql.jdbc.Driver
Dependent class: oracle.oc4j.sql.config.DataSourceConfigUtils
Loader: oc4j:10.1.3
Code-Source: /C:/JDeveloper10g/j2ee/home/lib/oc4j-internal.jar
Configuration: <code-source> in META-INF/boot.xml in C:\JDeveloper10g\j2ee\home\oc4j.jar
This load was initiated at current-workspace-app.root:0.0.0 using the Class.forName() method.
The missing class is not available from any code-source or loader in the system.
at oracle.classloader.PolicyClassLoader.handleClassNotFound(PolicyClassLoader.java:2061)
at oracle.classloader.PolicyClassLoader.internalLoadClass(PolicyClassLoader.java:1665)
at oracle.classloader.PolicyClassLoader.loadClass(PolicyClassLoader.java:1621)
at oracle.classloader.PolicyClassLoader.loadClass(PolicyClassLoader.java:1606)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at oracle.oc4j.sql.config.DataSourceConfigUtils.createConnectionFactory(DataSourceConfigUtils.java:244)
... 15 more
06/01/31 21:41:08 WARNING: Application.setConfig Application: current-workspace-app is in failed state as initialization failedjava.lang.InstantiationException: Error occurred initializing connectors. Exception is: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
Jan 31, 2006 9:41:08 PM com.evermind.server.Application setConfig
WARNING: Application: current-workspace-app is in failed state as initialization failedjava.lang.InstantiationException: Error occurred initializing connectors. Exception is: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
2006-01-31 21:41:08.531 WARNING J2EE 0JR0013 Exception initializing deployed application: current-workspace-app. Error occurred initializing connectors. Exception is: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
Ready message received from Oc4jNotifier.
Embedded OC4J startup time: 29125 ms.I did what Manu suggested with no success. Alternatively, I registered the driver jar with embedded OC4J preferences > global > libraries. Still does not work. Please, note, that when I run JUnit tests against my BC4J application modules with JDBC URL as connection type, everything works just fine. The problem comes while running the JSF application when the application module is using JDBC DataSource as connection type.
-
Heterogeneous Connectivity to MySQL with ODBC 5.1
Hi,
I have a setup with an oracle 10g XE version on an windows Server 2003 together with a MySQL 5.5
I setup a Heterogeneous Link using MySQL ODBC 5.1.
Every time I select something from a mysql table all varchar and text fields ignored in result set.
so the
select * from project@sugarcrm
returns only the non text/varchar fields (dates,numeric)
the select name from project@sugarcrm where name is char fiels
returns ORA-00904 'name invalid identifier '
ThanksI was looking for the sql.log in defined path if was in c:\ ...
odbcad32 1860-2944 ENTER SQLAllocHandle
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 00000000
SQLHANDLE * 0007D2C0
odbcad32 1860-2944 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 00000000
SQLHANDLE * 0x0007D2C0 ( 0x009f14e8)
odbcad32 1860-2944 ENTER SQLSetEnvAttr
SQLHENV 009F14E8
SQLINTEGER 200 <SQL_ATTR_ODBC_VERSION>
SQLPOINTER 0x00000003
SQLINTEGER 0
odbcad32 1860-2944 EXIT SQLSetEnvAttr with return code 0 (SQL_SUCCESS)
SQLHENV 009F14E8
SQLINTEGER 200 <SQL_ATTR_ODBC_VERSION>
SQLPOINTER 0x00000003 (BADMEM)
SQLINTEGER 0
odbcad32 1860-2944 ENTER SQLAllocHandle
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 009F14E8
SQLHANDLE * 0007D2BC
odbcad32 1860-2944 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 009F14E8
SQLHANDLE * 0x0007D2BC ( 0x009f1590)
odbcad32 1860-2944 ENTER SQLDriverConnectW
HDBC 009F1590
HWND 00000000
WCHAR * 0x4BF78088 [ -3] "******\ 0"
SWORD -3
WCHAR * 0x4BF78088
SWORD 2
SWORD * 0x00000000
UWORD 0 <SQL_DRIVER_NOPROMPT>
odbcad32 1860-2944 EXIT SQLDriverConnectW with return code 0 (SQL_SUCCESS)
HDBC 009F1590
HWND 00000000
WCHAR * 0x4BF78088 [ -3] "******\ 0"
SWORD -3
WCHAR * 0x4BF78088
SWORD 2
SWORD * 0x00000000
UWORD 0 <SQL_DRIVER_NOPROMPT>
odbcad32 1860-2944 ENTER SQLAllocHandle
SQLSMALLINT 3 <SQL_HANDLE_STMT>
SQLHANDLE 009F1590
SQLHANDLE * 0007D2B8
odbcad32 1860-2944 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 3 <SQL_HANDLE_STMT>
SQLHANDLE 009F1590
SQLHANDLE * 0x0007D2B8 ( 0x009f21c8)
odbcad32 1860-2944 ENTER SQLTablesW
HSTMT 009F21C8
WCHAR * 0x01336BC8 [ -3] "%\ 0"
SWORD -3
WCHAR * 0x01336BCC [ -3] "\ 0"
SWORD -3
WCHAR * 0x01336BCC
SWORD 0
WCHAR * 0x01336BCC
SWORD 0
odbcad32 1860-2944 EXIT SQLTablesW with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
WCHAR * 0x01336BC8 [ -3] "%\ 0"
SWORD -3
WCHAR * 0x01336BCC [ -3] "\ 0"
SWORD -3
WCHAR * 0x01336BCC
SWORD 0
WCHAR * 0x01336BCC
SWORD 0
odbcad32 1860-2944 ENTER SQLBindCol
HSTMT 009F21C8
UWORD 1
SWORD -8 <SQL_C_WCHAR>
PTR 0x0007D2CC
SQLLEN 255
SQLLEN * 0x0007D2C8
odbcad32 1860-2944 EXIT SQLBindCol with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
UWORD 1
SWORD -8 <SQL_C_WCHAR>
PTR 0x0007D2CC
SQLLEN 255
SQLLEN * 0x0007D2C8 (2000326715)
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 100 (SQL_NO_DATA_FOUND)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFreeHandle
SQLSMALLINT 3 <SQL_HANDLE_STMT>
SQLHANDLE 009F21C8
odbcad32 1860-2944 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 3 <SQL_HANDLE_STMT>
SQLHANDLE 009F21C8
odbcad32 1860-2944 ENTER SQLDisconnect
HDBC 009F1590
odbcad32 1860-2944 EXIT SQLDisconnect with return code 0 (SQL_SUCCESS)
HDBC 009F1590
odbcad32 1860-2944 ENTER SQLFreeHandle
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 009F1590
odbcad32 1860-2944 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 009F1590
odbcad32 1860-2944 ENTER SQLFreeHandle
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 009F14E8
odbcad32 1860-2944 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 009F14E8
odbcad32 1860-2944 ENTER SQLAllocHandle
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 00000000
SQLHANDLE * 0007CFF8
odbcad32 1860-2944 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 00000000
SQLHANDLE * 0x0007CFF8 ( 0x009f14e8)
odbcad32 1860-2944 ENTER SQLSetEnvAttr
SQLHENV 009F14E8
SQLINTEGER 200 <SQL_ATTR_ODBC_VERSION>
SQLPOINTER 0x00000003
SQLINTEGER 0
odbcad32 1860-2944 EXIT SQLSetEnvAttr with return code 0 (SQL_SUCCESS)
SQLHENV 009F14E8
SQLINTEGER 200 <SQL_ATTR_ODBC_VERSION>
SQLPOINTER 0x00000003 (BADMEM)
SQLINTEGER 0
odbcad32 1860-2944 ENTER SQLAllocHandle
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 009F14E8
SQLHANDLE * 0007CFF4
odbcad32 1860-2944 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 009F14E8
SQLHANDLE * 0x0007CFF4 ( 0x009f1590)
odbcad32 1860-2944 ENTER SQLDriverConnectW
HDBC 009F1590
HWND 00000000
WCHAR * 0x4BF78088 [ -3] "******\ 0"
SWORD -3
WCHAR * 0x4BF78088
SWORD 2
SWORD * 0x00000000
UWORD 0 <SQL_DRIVER_NOPROMPT>
odbcad32 1860-2944 EXIT SQLDriverConnectW with return code 0 (SQL_SUCCESS)
HDBC 009F1590
HWND 00000000
WCHAR * 0x4BF78088 [ -3] "******\ 0"
SWORD -3
WCHAR * 0x4BF78088
SWORD 2
SWORD * 0x00000000
UWORD 0 <SQL_DRIVER_NOPROMPT>
odbcad32 1860-2944 ENTER SQLAllocHandle
SQLSMALLINT 3 <SQL_HANDLE_STMT>
SQLHANDLE 009F1590
SQLHANDLE * 0007CFF0
odbcad32 1860-2944 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 3 <SQL_HANDLE_STMT>
SQLHANDLE 009F1590
SQLHANDLE * 0x0007CFF0 ( 0x009f21c8)
odbcad32 1860-2944 ENTER SQLExecDirectW
HSTMT 009F21C8
WCHAR * 0x01336BD0 [ -3] "SHOW CHARACTER SET\ 0"
SDWORD -3
odbcad32 1860-2944 EXIT SQLExecDirectW with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
WCHAR * 0x01336BD0 [ -3] "SHOW CHARACTER SET\ 0"
SDWORD -3
odbcad32 1860-2944 ENTER SQLBindCol
HSTMT 009F21C8
UWORD 1
SWORD -8 <SQL_C_WCHAR>
PTR 0x0007D004
SQLLEN 255
SQLLEN * 0x0007D000
odbcad32 1860-2944 EXIT SQLBindCol with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
UWORD 1
SWORD -8 <SQL_C_WCHAR>
PTR 0x0007D004
SQLLEN 255
SQLLEN * 0x0007D000 (512124)
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 0 (SQL_SUCCESS)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFetch
HSTMT 009F21C8
odbcad32 1860-2944 EXIT SQLFetch with return code 100 (SQL_NO_DATA_FOUND)
HSTMT 009F21C8
odbcad32 1860-2944 ENTER SQLFreeHandle
SQLSMALLINT 3 <SQL_HANDLE_STMT>
SQLHANDLE 009F21C8
odbcad32 1860-2944 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 3 <SQL_HANDLE_STMT>
SQLHANDLE 009F21C8
odbcad32 1860-2944 ENTER SQLDisconnect
HDBC 009F1590
odbcad32 1860-2944 EXIT SQLDisconnect with return code 0 (SQL_SUCCESS)
HDBC 009F1590
odbcad32 1860-2944 ENTER SQLFreeHandle
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 009F1590
odbcad32 1860-2944 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 009F1590
odbcad32 1860-2944 ENTER SQLFreeHandle
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 009F14E8
odbcad32 1860-2944 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 009F14E8 -
hello everyone,
can we anyone help me with small example, how to connect j2me with mysql.Put all your Database transactions in server side, using Connection framework in J2ME, access that URL by your device. Here is a snap to access a URL to get the message returned by that URL.
public String getMessage(String url)
HttpConnection hc = (HttpConnection)Connector.open( url, Connector.READ_WRITE );
hc.setRequestMethod( HttpConnection.POST );
InputStream in=hc.openInputStream();
DataInputStream dis=new DataInputStream(in);
int ch;
String msg="";
while((ch=dis.read())!= -1)
msg=""+msg+(char)ch;
reutrn msg;
} -
Please help regarding method/function sign up validation with mysql jdbc.
HI guys,
I am have been fixing this problem for days, hope that someone could help me find the bug on my code.
I have 3 files:
1.WithAuth.java - for database jdbc mysql connection
2.WithAuthMet.java - method that will read any variables that will be passed to it. this method is waiting for two variables, a and b. a for userName and b for userPassword.
3.WithAuthTest.java - the testing class, this is where i declare my sample control data to test the database connection and query.
here's the actual codes:
WithAuth.java
package com.Auth;
public class WithAuth {
static String userName = "root";
static String userPassword = "";
static String databaseUrl = "jdbc:mysql://localhost:3306/javatowebservice";
static String userQuery = "select * from userlogin";
}WithAuthMet.java
- this is where the error is and where I messed up.
package com.Auth;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class WithAuthMet extends WithAuth {
public void connect(String a, String b)throws Exception{
//try {
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
Connection conn = DriverManager.getConnection (databaseUrl, userName, userPassword);
Statement stat = conn.createStatement();
String query = userQuery;
ResultSet result = stat.executeQuery(query);
System.out.println("Result(s): ");
while (result.next ()){
int i = result.getInt("userId");
String name=result.getString("userName");
String password=result.getString("userPassword");
//System.out.println("test data:"+a);
if(a.equals(name.equals("userName"))&& b.equals(password.equals("userPassword"))){
System.out.println("User is Valid");
else{
System.out.println("You are not a Valid User");
System.out.println("test data:"+name);
System.out.println("test data:"+password);
System.out.println("test data:"+a);
System.out.println("test data:"+b);
//conn.close();
// }catch(Exception e){
//System.out.println("Exception is ;"+e);
//System.out.println("Exception is ;");
// if(a.equals(name.("userName"))
// && password.equals(password.equals("userPassword"))){
// System.out.println("User is Valid");
// else{
// System.out.println("You are not a Valid User");
} WithAuthTest.java
package com.Auth;
public class WithAuthTest extends WithAuthMet{
public static void main(String[] args) throws Exception{
WithAuthMet CTD = new WithAuthMet();
String a = "dan";
String b = "password";
//CTD.connect(String name,String password);
CTD.connect(a, b);
//return connect;
}please help.yakultyakultyakult wrote:
WithAuthMet.java
- this is where the error is and where I messed up.
package com.Auth;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class WithAuthMet extends WithAuth {
public void connect(String a, String b)throws Exception{
//try {
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
Connection conn = DriverManager.getConnection (databaseUrl, userName, userPassword);
Statement stat = conn.createStatement();
String query = userQuery;
ResultSet result = stat.executeQuery(query);
System.out.println("Result(s): ");
while (result.next ()){
int i = result.getInt("userId");
String name=result.getString("userName");
String password=result.getString("userPassword");
//System.out.println("test data:"+a);
if(a.equals(name.equals("userName"))&& b.equals(password.equals("userPassword"))){
System.out.println("User is Valid");
else{
System.out.println("You are not a Valid User");
System.out.println("test data:"+name);
System.out.println("test data:"+password);
System.out.println("test data:"+a);
System.out.println("test data:"+b);
//conn.close();
// }catch(Exception e){
//System.out.println("Exception is ;"+e);
//System.out.println("Exception is ;");
// if(a.equals(name.("userName"))
// && password.equals(password.equals("userPassword"))){
// System.out.println("User is Valid");
// else{
// System.out.println("You are not a Valid User");
This is one line that is wrong
if(a.equals(name.equals("userName"))&& b.equals(password.equals("userPassword"))){You have 'a' and 'b which are Strings
and you are comparing them [using equals()] with the boolean return from another set of equals() invocations.
String equals boolean will always be false (well, maybe not if the String is "TRUE" or "FALSE" - and you would need some more boilerplate to make that work). -
compile and build:Successful
but when I run it...I got this msg:
init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\Administrator\Form\build\classes
compile:
run:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at my.form.MyDBConnection.init(MyDBConnection.java:26)
at my.form.FormUI.<init>(FormUI.java:20)
at my.form.FormUI$40.run(FormUI.java:1094)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
I use two classes
FormUI.java and MyDBConnection.java
* MyDBConnection.java
package my.form;
import java.sql.*;
public class MyDBConnection {
private Connection myConnection;
/** Creates a new instance of MyDBConnection */
public MyDBConnection() {
public void init(){
Connection connection = null;
Statement statement = null;
try{
Class.forName("com.mysql.jdbc.Driver");
myConnection=DriverManager.getConnection(
"jdbc:mysql://localhost:3306/test,'root' "
catch(SQLException sqlException){
sqlException.printStackTrace();
System.exit(1);
catch ( ClassNotFoundException classNotFound )
classNotFound.printStackTrace();
System.exit(1);
finally
try
statement.close();
connection.close();
catch ( Exception exception )
exception.printStackTrace();
System.exit( 1 );
public Connection getMyConnection(){
return myConnection;
public void close(ResultSet rs){
if(rs !=null){
try{
rs.close();
catch(Exception e){}
public void close(java.sql.Statement stmt){
if(stmt !=null){
try{
stmt.close();
catch(Exception e){}
public void destroy(){
if(myConnection !=null){
try{
myConnection.close();
catch(Exception e){}
* FormUI.java
* Created on May 2, 2007, 10:33 AM
package my.form;
import java.sql.*;
* @author Administrator
public class FormUI extends javax.swing.JFrame {
/** Creates new form FormUI */
public FormUI() throws Exception {
mdbc=new MyDBConnection();
mdbc.init();
Connection conn=mdbc.getMyConnection();
stmt=conn.createStatement();
initComponents();
* MyDBConnection.java
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField35 = new javax.swing.JTextField();
jPanel3 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
jTextField5 = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
jTextField6 = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
jTextField7 = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
jTextField4 = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
jTextField8 = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
jTextField9 = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
jTextField10 = new javax.swing.JTextField();
jLabel12 = new javax.swing.JLabel();
jTextField11 = new javax.swing.JTextField();
jLabel13 = new javax.swing.JLabel();
jTextField12 = new javax.swing.JTextField();
jLabel14 = new javax.swing.JLabel();
jTextField13 = new javax.swing.JTextField();
jLabel15 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jLabel16 = new javax.swing.JLabel();
jTextField14 = new javax.swing.JTextField();
jLabel17 = new javax.swing.JLabel();
jTextField15 = new javax.swing.JTextField();
jLabel18 = new javax.swing.JLabel();
jTextField16 = new javax.swing.JTextField();
jLabel19 = new javax.swing.JLabel();
jTextField17 = new javax.swing.JTextField();
jLabel20 = new javax.swing.JLabel();
jTextField18 = new javax.swing.JTextField();
jLabel21 = new javax.swing.JLabel();
jTextField19 = new javax.swing.JTextField();
jLabel22 = new javax.swing.JLabel();
jTextField20 = new javax.swing.JTextField();
jLabel23 = new javax.swing.JLabel();
jTextField21 = new javax.swing.JTextField();
jLabel24 = new javax.swing.JLabel();
jTextField22 = new javax.swing.JTextField();
jLabel25 = new javax.swing.JLabel();
jTextField23 = new javax.swing.JTextField();
jLabel26 = new javax.swing.JLabel();
jTextField24 = new javax.swing.JTextField();
jLabel27 = new javax.swing.JLabel();
jTextField25 = new javax.swing.JTextField();
jLabel28 = new javax.swing.JLabel();
jTextField26 = new javax.swing.JTextField();
jLabel29 = new javax.swing.JLabel();
jTextField27 = new javax.swing.JTextField();
jLabel30 = new javax.swing.JLabel();
jTextField28 = new javax.swing.JTextField();
jLabel31 = new javax.swing.JLabel();
jTextField29 = new javax.swing.JTextField();
jLabel32 = new javax.swing.JLabel();
jTextField30 = new javax.swing.JTextField();
jLabel33 = new javax.swing.JLabel();
jTextField31 = new javax.swing.JTextField();
jLabel34 = new javax.swing.JLabel();
jTextField32 = new javax.swing.JTextField();
jLabel35 = new javax.swing.JLabel();
jTextField33 = new javax.swing.JTextField();
jLabel36 = new javax.swing.JLabel();
jTextField34 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel37 = new javax.swing.JLabel();
jLabel38 = new javax.swing.JLabel();
jTextField37 = new javax.swing.JTextField();
jTextField36 = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBackground(new java.awt.Color(204, 255, 204));
jLabel1.setText("custID");
jLabel2.setText("PIN");
jLabel3.setText("Source");
jLabel4.setText("SaleDate");
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
jTextField3.setText("SourceHub");
jTextField3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField3ActionPerformed(evt);
jTextField35.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField35ActionPerformed(evt);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(28, 28, 28)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addGap(15, 15, 15)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 88, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3)
.addComponent(jLabel4))
.addGap(13, 13, 13)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextField35)
.addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE))
.addGap(198, 198, 198))
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(jTextField35, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(23, Short.MAX_VALUE))
jPanel3.setBackground(new java.awt.Color(204, 255, 204));
jLabel5.setText("First Name");
jTextField5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField5ActionPerformed(evt);
jLabel6.setText("Last Name");
jTextField6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField6ActionPerformed(evt);
jLabel7.setText("Address");
jTextField7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField7ActionPerformed(evt);
jLabel8.setText("City");
jTextField4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField4ActionPerformed(evt);
jLabel9.setText("ZIP");
jTextField8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField8ActionPerformed(evt);
jLabel10.setText("Sales Rep");
jTextField9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField9ActionPerformed(evt);
jLabel11.setText("Phone");
jTextField10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField10ActionPerformed(evt);
jLabel12.setText("Alt Phone");
jTextField11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField11ActionPerformed(evt);
jLabel13.setText("E-Mail");
jTextField12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField12ActionPerformed(evt);
jLabel14.setText("DateofBirth");
jTextField13.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField13ActionPerformed(evt);
jPanel2.setBackground(new java.awt.Color(204, 255, 204));
jLabel16.setText("AnnualAmount");
jTextField14.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField14ActionPerformed(evt);
jLabel17.setText("AnnualDay");
jTextField15.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField15ActionPerformed(evt);
jLabel18.setText("AnnualMonth");
jTextField16.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField16ActionPerformed(evt);
jLabel19.setText("MonthlyAmount");
jTextField17.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField17ActionPerformed(evt);
jLabel20.setText("MonthlyDay");
jTextField18.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField18ActionPerformed(evt);
jLabel21.setText("MonthlyStatusDate");
jTextField19.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField19ActionPerformed(evt);
jLabel22.setText("AnnualStatus2");
jTextField20.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField20ActionPerformed(evt);
jLabel23.setText("MonthlyStatus2");
jTextField21.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField21ActionPerformed(evt);
jLabel24.setText("Plan");
jTextField22.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField22ActionPerformed(evt);
jLabel25.setText("Bonus Gift");
jTextField23.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField23ActionPerformed(evt);
jLabel26.setText("AccountType");
jTextField24.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField24ActionPerformed(evt);
jLabel27.setText("AbaNumber");
jTextField25.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField25ActionPerformed(evt);
jLabel28.setText("AccountNumber");
jTextField26.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField26ActionPerformed(evt);
jLabel29.setText("BankName");
jTextField27.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField27ActionPerformed(evt);
jLabel30.setText("Verification Number");
jTextField28.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField28ActionPerformed(evt);
jLabel31.setText("Upsale1");
jTextField29.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField29ActionPerformed(evt);
jLabel32.setText("Upsale2");
jTextField30.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField30ActionPerformed(evt);
jLabel33.setText("UP1BillDate");
jTextField31.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField31ActionPerformed(evt);
jLabel34.setText("UP2BillDate");
jTextField32.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField32ActionPerformed(evt);
jLabel35.setText("Date-Time");
jTextField33.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField33ActionPerformed(evt);
jLabel36.setText("Notes");
jTextField34.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField34ActionPerformed(evt);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel16)
.addComponent(jLabel19)
.addComponent(jLabel22)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(34, 34, 34)
.addComponent(jLabel24))
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel26))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(23, 23, 23)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel29)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(2, 2, 2)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel31)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel35)
.addComponent(jLabel33)))))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextField24)
.addComponent(jTextField22)
.addComponent(jTextField20)
.addComponent(jTextField17)
.addComponent(jTextField14, javax.swing.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel17)
.addComponent(jLabel20))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextField18)
.addComponent(jTextField15, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel18)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField16, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel21)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField19, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel27)
.addComponent(jLabel25)
.addComponent(jLabel23))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextField25)
.addComponent(jTextField23)
.addComponent(jTextField21, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField28, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel28)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField26))))))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jTextField31, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField29, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField27, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE))
.addGap(21, 21, 21)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel30)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
.addComponent(jLabel34)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(14, 14, 14)
.addComponent(jTextField34, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField32, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
.addComponent(jLabel32)
.addGap(20, 20, 20)
.addComponent(jTextField30, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jTextField33, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27)
.addComponent(jLabel36)))
.addGap(113, 11I am not sure what is the driver for mysql. I just came across the similar kind of problem in the forum and I have given the forum link below. Check if you have the file and then set the classpath.
[Hyperlinks] http://forum.java.sun.com/thread.jspa?threadID=522873&messageID=2503366
[HyperLinks] -
I began playing with JDBC a few days ago. I set up a database using mySQL and wrote a simple java program that will connect to it. Works good from the computer that holds the database.
I try and run the same program from my secondary computer which does not have mySQL or ODBC mySQL drivers, I get com.mysql.jdbc.Driver for an error message. (Trying to access the database on my main computer via ip/databasename)
My Question is, do you HAVE to have mySQL or Connector/ODBC installed on a computer if you wish to connect to a database on other computer??
Here's where it prints the error message...
try
Class.forName("com.mysql.jdbc.Driver");
catch (Exception e)
JOptionPane.showMessageDialog(null, "ERROR = " + e.getMessage());
I use this as my url..
private final String url = "jdbc:mysql://122.122.122.122:3306/test123";
Say I want to make a simple web applet that will
access a database on my computer. The only way my
vistors to my website will be able to access the
database via the web applet is by having mySQL JDBC
driver installed on their computers?yes.
however.
you can package up the JDBC driver as part of your jar with your applet so it doesn't require the user to "install" anything. it's just part of your applet. -
Hi,
I need help connecting to a MySQL db through oracle reports using a jdbc connection.
I have downloaded the MySQL JDBC driver:mysql-connector-java-3.0.17-ga-bin.jar.
I can succesfully use it to connect if I write a simple java program. So I know the driver works.
I have set it in my classpath & edited the jdbcpds.conf file by adding the following:
<driver name = "mysql-merant"
sourceDatabase = "other"
subProtocol = "mysql"
connectString = "mainProtocol:subProtocol://databaseName"
class = "com.mysql.jdbc.Driver"
connection = "oracle.reports.plugin.datasource.jdbcpds.JDBCConnectionHandling">
</driver>
When I try to connect, I get the following error, ERR 62002 failed to connect to the data source.
What do I have to do to connect? Is there a way to directly give the connect string?
I can connect to an oracle DB using a the Oracle drivers no problem, why does forms not accept the MySQL driver? What can I do to make this work?
Any help would be appreciated.
Michael Baran
[email protected]With Reports 9i the mysql-connector-java doesn´t work for that. You don´t have to edit the jdbcpds.conf. mysql-merant doesn´t exist. Just download MyODBC conector and then stand up your database in your DSN system. Use the wizard to make a report, then use JDBC Query and using jdbc-odbc driver, fill the fields
then you have connected MySQL
very easy.
I hope this help you -
When I run this program, the result set show up in the results textarea but it does not start a new line after each record even after inserting the "\n" escape character
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
import javax.swing.*;
* @author wezi
* A java program for keeping track of the inventory of
* books belonging to the ACM bookclub of Riverside
public class ACMBooks extends JFrame
private JTabbedPane mainTab;
private JPanel connectpane, querypane, processpane, adminpane;
private JPanel quadpane[] = new JPanel[4];
//components for pane 1
private JTextField txtUser, txtPort, txtHost, txtdb;
private JLabel lbluser, lblpasswd, lblport, lblhost, lbldb, lblstatus;
private JPasswordField pwdconnect;
private JButton btnConnect ;
private String tooltip[] = {"Default Name = bookdb","",
"Default port for MySQL = 3306",
"Default host is localhost", "Default database is acmbooks"};
//Components for pane 2
private JPanel sqlpane, searchpane, resultspane;
private JTextArea txaSQL, txaResults;
private JButton btnQuery, btnSearch, btnReset;
private JLabel lblAuthor, lblTitle, lblISBN, lblCategory;
private JTextField txtauthor, txttitle, txtisbn, txtCat;
private JScrollPane scroller;
//Components for panel 3
private JPanel checkIn, checkOut;
private GridLayout gl,gl2, gl3;
private GridBagLayout gbl = new GridBagLayout();
private GridBagConstraints gbc = new GridBagConstraints();
private GridBagConstraints gbc2 = new GridBagConstraints();
//private String pwd;
//Set up the GUI
public ACMBooks()
super("ACM Book Library");
lbldb = new JLabel("Database");
lblstatus = new JLabel("Connection settings");
gl = new GridLayout(2,2);
Container cont = getContentPane();
mainTab = new JTabbedPane();
connectpane = new JPanel();
adminpane = new JPanel();
//set up the connection pane GUI
connectpane.setLayout(gl);
for(int i=0; i<4; i++)
quadpane[i] = new JPanel();
connectpane.add(quadpane);
gbc.insets = new Insets(0,20,0,0);
quadpane[0].setLayout(gbl);
lbluser = new JLabel("User Name:");
gbc.anchor = GridBagConstraints.NORTHEAST;
gbc.gridx = 0; gbc.gridy = 0;
gbc.weightx = 0.5; gbc.weighty = 0.5;
quadpane[0].add(lbluser,gbc);
lblpasswd = new JLabel("Password:");
gbc.gridx = 0; gbc.gridy = 1;
quadpane[0].add(lblpasswd,gbc);
lblport = new JLabel("Port:");
gbc.gridx = 0; gbc.gridy = 2;
quadpane[0].add(lblport,gbc);
lblhost = new JLabel("Host:");
gbc.gridx = 0; gbc.gridy = 3;
quadpane[0].add(lblhost,gbc);
lbldb = new JLabel("Database:");
gbc.gridx = 0; gbc.gridy = 4;
quadpane[0].add(lbldb,gbc);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.insets = new Insets(0,10,0,0);
gbc.gridx = 1; gbc.gridy = 0;
txtUser = new JTextField(10);
txtUser.setToolTipText("Default username = bookdb");
quadpane[0].add(txtUser,gbc);
gbc.gridx = 1; gbc.gridy = 2;
txtPort = new JTextField(10);
txtPort.setToolTipText("Default port = 3306");
quadpane[0].add(txtPort,gbc);
gbc.gridx = 1; gbc.gridy = 3;
txtHost = new JTextField(10);
txtHost.setToolTipText("Default host = localhost");
quadpane[0].add(txtHost,gbc);
gbc.gridx = 1; gbc.gridy = 4;
txtdb = new JTextField(10);
txtdb.setToolTipText("Default database = acmbooks");
quadpane[0].add(txtdb,gbc);
pwdconnect = new JPasswordField(10);
gbc.gridx = 1; gbc.gridy = 1;
quadpane[0].add(pwdconnect,gbc);
//Create a connection button
btnConnect = new JButton("Connect");
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 2; gbc.gridy = 4;
quadpane[0].add(btnConnect,gbc);
//create the reset button
btnReset = new JButton(" Reset ");
btnReset.setSize(btnConnect.getHeight(),btnConnect.getWidth());
gbc.gridx = 2; gbc.gridy = 3;
quadpane[0].add(btnReset,gbc);
//Connection status
lblstatus = new JLabel();
quadpane[3].setLayout(gbl);
gbc.anchor = GridBagConstraints.SOUTHEAST;
gbc.insets = new Insets(0,10,20,20);
quadpane[3].add(lblstatus,gbc);
//Add a border to the first pane & add it to the main container
quadpane[0].setBorder(BorderFactory.createTitledBorder("Details"));
mainTab.addTab("Connection Settings",null,connectpane,"connections");
//Create the second tab (Query pane)
querypane = new JPanel();
GridBagLayout gblquery= new GridBagLayout();
GridBagConstraints gbcquery = new GridBagConstraints();
gl2 = new GridLayout(4,1);
querypane.setLayout(gblquery);
//The sql query pane
sqlpane = new JPanel();
sqlpane.setLayout(gbl);
gbc2.gridx = 0; gbc2.gridy = 0;
gbc2.weightx = 0.5; gbc2.weighty = 0.5;
txaSQL = new JTextArea(4,44);
txaSQL.setBorder(BorderFactory.createLoweredBevelBorder());
gbc2.anchor = GridBagConstraints.NORTHWEST;
gbc2.insets = new Insets(0,10,0,0);
sqlpane.add(txaSQL,gbc2);
gbc2.gridx = 1; gbc2.gridy = 0;
btnQuery = new JButton("Enter Query");
gbc2.insets = new Insets(0,16,5,10);
gbc2.anchor = GridBagConstraints.SOUTHEAST;
sqlpane.add(btnQuery,gbc2);
sqlpane.setBorder(BorderFactory.createTitledBorder("SQL Queries:"));
gbcquery.gridheight =1; gbcquery.gridwidth = 1;
gbcquery.gridx = 0; gbcquery.gridy = 0;
gbcquery.anchor = GridBagConstraints.NORTHWEST;
gbcquery.weightx = 0.5; gbcquery.weighty =0.5;
gbcquery.fill =GridBagConstraints.REMAINDER;
gbcquery.insets = new Insets(0,0,2,0);
gbcquery.ipadx = 1; gbcquery.ipady = 1;
querypane.add(sqlpane,gbcquery);
//The search by pane
searchpane = new JPanel();
searchpane.setLayout(gbl);
gbc2.insets = new Insets(0,14,5,5);
lblAuthor = new JLabel("Author:");
gbc2.anchor = GridBagConstraints.NORTHEAST;
gbc2.gridx = 0; gbc2.gridy = 0;
searchpane.add(lblAuthor,gbc2);
lblTitle = new JLabel("Title:");
gbc2.gridx = 0; gbc2.gridy = 1;
searchpane.add(lblTitle,gbc2);
lblISBN = new JLabel("ISBN:");
gbc2.gridx = 2; gbc2.gridy = 0;
searchpane.add(lblISBN,gbc2);
lblCategory = new JLabel("Category:");
gbc2.gridx = 2; gbc2.gridy =1;
searchpane.add(lblCategory,gbc2);
txtauthor = new JTextField(15);
gbc2.gridx = 1; gbc2.gridy = 0;
gbc2.anchor = GridBagConstraints.NORTHWEST;
searchpane.add(txtauthor,gbc2);
txttitle = new JTextField(15);
gbc2.gridx = 1; gbc2.gridy = 1;
searchpane.add(txttitle,gbc2);
txtisbn = new JTextField(15);
gbc2.gridx = 3; gbc2.gridy = 0;
searchpane.add(txtisbn,gbc2);
txtCat = new JTextField(15);
gbc2.gridx = 3; gbc2.gridy = 1;
searchpane.add(txtCat,gbc2);
btnSearch = new JButton("Search >>>");
gbc2.anchor = GridBagConstraints.SOUTHEAST;
gbc2.gridx = 4; gbc2.gridy = 1;
gbc2.insets = new Insets(0,5,20,10);
searchpane.add(btnSearch,gbc2);
searchpane.setBorder(BorderFactory.createTitledBorder("Search By:"));
gbcquery.gridheight =1; gbcquery.gridwidth = 1;
gbcquery.gridx = 0; gbcquery.gridy = 1;
gbcquery.insets = new Insets(0,0,0,0);
querypane.add(searchpane,gbcquery);
//The results pane
resultspane = new JPanel();
resultspane.setSize(20,60);
resultspane.setLayout(gbl);
gbc2.gridx = 0; gbc2.gridy = 0;
gbc2.anchor = GridBagConstraints.NORTHWEST;
txaResults = new JTextArea(" ",9,55);
scroller = new JScrollPane(txaResults);
resultspane.add(new JScrollPane(txaResults));
txaResults.setBorder(BorderFactory.createLoweredBevelBorder());
resultspane.add(txaResults,gbc2);
resultspane.setBorder(BorderFactory.createTitledBorder("Results:"));
gbcquery.gridheight =3; gbcquery.gridwidth = 1;
gbcquery.gridx = 0; gbcquery.gridy = 2;
gbcquery.weightx = 1; gbcquery.weighty = 1;
querypane.add(resultspane,gbcquery);
mainTab.addTab("Query Entry",null,querypane,"Query page");
//Create a third tab to process book checkin and out
processpane = new JPanel();
gl3 = new GridLayout(4,1);
processpane.setLayout(gl3);
//Create the checkin panel
checkIn = new JPanel();
checkIn.setBorder(BorderFactory.createTitledBorder("Return Books"));
checkIn.setLayout(gbl);
//Create the checkout panel
checkOut = new JPanel();
checkOut.setBorder(BorderFactory.createTitledBorder("Check Books Out"));
processpane.add(checkOut,gl3);
processpane.add(checkIn,gl3);
mainTab.addTab("Process Books",null, processpane,"Book Processing page");
//Create an administration panel
adminpane = new JPanel();
mainTab.addTab("Admin",null,adminpane,"Administration page");
cont.add(mainTab);
//Register the eventhandlers
ButtonHandler btnHandler = new ButtonHandler();
btnConnect.addActionListener(btnHandler);
btnQuery.addActionListener(btnHandler);
btnSearch.addActionListener(btnHandler);
btnReset.addActionListener(btnHandler);
setSize(650,460);
setVisible(true);
}//end constructor
private class ButtonHandler implements ActionListener
public void actionPerformed(ActionEvent e)
String errMsg;
Statement stmt;
ResultSet rs;
Connection con = null;
String pwd;
String user;
//Create a url from user input
String url = "jdbc:mysql://";
url += txtHost.getText();
url += ":";
url += txtPort.getText();
url += "/";
url += txtdb.getText();
try
//Register the JDBC Mysql Driver
Class.forName("com.mysql.jdbc.Driver");
//Get the password and user name for the database
pwd = new String(pwdconnect.getPassword());
user = new String(txtUser.getText());
//Open a connection to the database
con = DriverManager.getConnection(url,user,pwd);
//Add the action event for the btnReset
if(e.getSource() == btnReset)
//Clear all the text fields and the status label
lblstatus.setText(" ");
txtUser.setText(" ");
txtdb.setText(" ");
txtHost.setText(" ");
txtPort.setText(" ");
pwdconnect.setText("");
txaResults.setText(" ");
txaSQL.setText(" ");
try{
if(!con.isClosed())
con.close();
catch(Exception closeError)
String clErr = new String(closeError.toString());
txaResults.setText(clErr);
}//end btnReset
//If the connect button is pressed
if(e.getSource() == btnConnect)
if(!con.isClosed())//if connection is open
lblstatus.setText("");
lblstatus.setVisible(true);
lblstatus.setText("Connected to " + txtdb.getText()
+" on " + txtHost.getText());
else
{ lblstatus.setText("Not Connected"); }
}//end btnConnect
if(e.getSource() == btnQuery || e.getSource()== txaSQL)
String strQuery = new String(txaSQL.getText());
ResultSetMetaData rsmtd;
int numCol;
try
stmt = con.createStatement();
rs = stmt.executeQuery(strQuery);
rsmtd = rs.getMetaData(); //to get metadata
numCol = rsmtd.getColumnCount(); //for number of columns
String strCol[] = new String[numCol];
String colName[] = new String[numCol];
String txaColumn = new String("");
String strHeading = new String("");
//Write the results of the query to the results text area
txaResults.setText(" ");
//Get the data from the result set
//first get the column headings
for(int i=1; i<=numCol; i++)
colName[i-1] = rsmtd.getColumnName(i);
strHeading += colName[i-1] + "\t";
txaResults.setText(strHeading + "\n");
while(rs.next())
//Get the values & create a display column
for(int i=1; i<=numCol; i++)
strCol[i-1] = rs.getString(i);
txaColumn += strCol[i-1] + "\t";
}//end for
//Display the values
txaResults.append( txaColumn + "\n");
catch(Exception sqlError)
txaResults.setText("");
String strSqlErr = new String(sqlError.toString());
txaResults.setText(strSqlErr);
}//end btnQuery
if(e.getSource() == btnSearch)
try
String strAuthor = new String(txtauthor.getText());
String strISBN = new String(txtisbn.getText());
String strTitle = new String(txttitle.getText());
String strCat = new String(txtCat.getText());
* Need to add code to change the search fields to
* any if the field is blank i.e if the field is blank
* search using a wild card. If all fields are blank, then
* do not search at all.
stmt = con.createStatement();
rs = stmt.executeQuery("Select * from books where" +
" bookAuthor = " + strAuthor +
" bookISBN = " + strISBN +
" bookTitle = " + strTitle +
"bookCategory = " + strCat);
catch(Exception searchError)
errMsg = new String(searchError.toString());
txaResults.setText("");
txaResults.setText(errMsg);
}//end btnSearch
catch(Exception connectError)
errMsg = new String(connectError.toString());
lblstatus.setText("");
lblstatus.setText(errMsg);
}//end actionPer
}//end ButtonHandler
public static void main(String[] args)
ACMBooks app = new ACMBooks();
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}//end main
}//end class ACMBooksHi,
Here is a template of Manifest file which you can use for your reference:
Manifest-Version: 1.0
Created-By: Apache Ant 1.5.1
Main-Class: com.pkg1.pkg2.MainClass
Class-Path: . ./libs/ ./libs/database-driver.jar ./libs/jdom.jar ./libs/xercesImpl.jar ./libs/log4j.jar ....
Name: com.pkg1.pkg2Main-Class: Specify the main class with complete package name
Class-Path: Put all the jar file name with path
<b>So the solution to your problem is to put you jar file name with the relative or complete path</b>
Thanks
Duke. -
MYSQL JDBC NoClassDefFoundError: org/aspectj/lang/Signature
i am trying to connect to a database via java using JDBC i have installed:
jdk1.5.0_01
mysql-connector-java-3.1.8-bin-g.jar
MySQL Server 4.1
Java works fine, MYSQL works fine from the command prompt but when it comes to testing using this simple java program
public class JdbcExample1 {
public static void main(String args[]) {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("localhost", "username", "password");
if(!con.isClosed())
System.out.println("Successfully connected to MySQL server...");
} catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
} finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
this compiles fine but when run i get the following error message
Exception in thread "main" java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at JdbcExample1.main(JdbcExample1.java:10)
class path is set as .;C:\Program Files\Java\jdk1.5.0_01\jre\lib\ext\mysql-connector-java-3.1.8-bin.java
any help or input on this error would be appreciated
thanks in advanced NeilHi, All:
I just read this thread of discussion and got valueable info to solve my problem in a similar fashion. I'd suggest the last poster, Anil, to re-read the whole thread to correct the possible problems stated.
I would just like to add my problem/solution scenario to this thread to share my experience. I assume that readers already went through the previous notes in this thread.
#1. Space in Path:
I installed
MySQL DB server in: "C:\Program Files\MySQL\MySQL Server 4.1"
MySQL JDBC Driver: D:\mysql\mysql-connector-java-3.1.8
It seems to me that the DB server installed directory is not affected by whether there is a space in path name. The JDBC Driver path, on the other hand, does have the side effect of the space in path name when accessing by the Java client.
#2. -g in JDBC Driver:
I have been using the driver mysql-connector-java-3.1.8-bin.jar. However, right before I needed to create my ant build.xml configuration file (more details later), I thought the instruction asked me to use the mysql-connector-java-3.1.8-bin-g.jar (the debug version as kpreiser indicated), and therefore I got the now-well-known "org/aspectj/lang/Signature" error. After I removed that "-g" from the JDBC driver extression in my build.xml file, it then works well. (Great tip, kpreiser.)
#3. Middlegen with Hibernate:
My situation is a bit more complicated, but the issue of "org/aspectj/lang/Signature" error was the same (finally resolved in #2). I was trying to use Middlegen to re-generate my Hibernate map files from the data schema. (Hibernate is an open source tool that lets you create JavaBean source file from a Hibernate map file to map to a database table (see http://www.hibernate.org/ for more details.) Since I re-factored my data schema in the database, I needed to re-generate the Hibernate map files (from data schema) so that I can in turn use the map files to re-generate the JavaBean code. I wanted to use the Middlegen tool (see http://www.hibernate.org/98.html for more details) to re-generate the map files from database schema. However, in order to use Middlegen properly, you need to create the ant build.xml file to do that job. So I had to resort to MiddlegenIDE (see http://ultimania.org/middlegenide/ for more details) to help generate that build.xml file. (This is where I had the -g specified for the JDBC driver in the build.xml file that caused the problem.) Once that build.xml file is generated, the use of ant (a Java make tool) with the build.xml file can generate the hibernate map files. From these map files, JavaBean source files can be generated using Hibernate CodeGenerator.hbm2java tool. (There are several other useful tools in Hibernate too to convert the database ddl schema and the JavaBean source file.)
Obviously, there are other approaches and tools that you can use (XDoclet for instance) for different situations, but I am only providing a high level overview on what you can do to be more productive if you are involved in a large and complicated project with Java/JDBC and ORM (Object/Relational Mapping).
Item #3 may sound complicated at first, but it's worth the time to learn the tools and concept. Once you are familiar with these tools (Eclipse, Hibernate, Middlegen, Ant, etc.), you will become more productive in responding to the dynamic nature of the high-tech world where changing requirements are the only constant. I hope that these separate tools will become more integrated and easier to use in the future, but for now they do the job well.
Thanks for the great tips and hope that this helps too.
- Shuh -
Connection mysql jdbc error ?
I have program java likes this :
import java.sql.*;
public class LoadDriver {
// Define the JDBC Driver and the database connection URL
public static final String DRIVER = "com.mysql.jdbc.Driver";
public static final String URL = "jdbc:mysql://localhost/java?user=test&password=test";
public static void main(String args[]) {
Connection conn = null;
Statement select = null;
ResultSet result = null;
try {
// load the driver dynamically
Class.forName(DRIVER);
// connect to the database
conn = DriverManager.getConnection(URL);
// perform a query. first create a Statement object from the connection
select = conn.createStatement();
// next execute a query (SQL string) and return the results in a ResultSet object
result = select.executeQuery("select fname, lname from names order by lname, fname");
// print out the results
while(result.next()) {
String fname = result.getString("fname"); // note these match the columns in the
String lname = result.getString("lname"); // SELECT statement (fname, lname)
System.out.println(fname+" "+lname);
// check if there was a problem executing the SQL statement
catch (SQLException e) {
System.err.println("SQL Exception: "+e.getMessage());
System.exit(1);
// if the JDBC driver is not in the CLASSPATH
catch (ClassNotFoundException e) {
System.err.println("Class not found: "+e.getMessage());
System.exit(1);
// catch any other exceptions
catch (Exception e) {
System.err.println("Other Exception: ");
System.err.println(e.getMessage());
System.exit(1);
// You want to close the connections no matter what happens!
finally {
try {
// close the result, query, and database connection
if (result != null) result.close();
if (select != null) select.close();
if (conn != null) conn.close();
catch (SQLException e) {
// one of the new cases where it's OK to just eat exceptions or at the most log them
System.err.println("Error closing connection: "+e.getMessage());
but i get errror likes this :
D:\Program Files\Java\jdk1.5.0_03\bin>javac LoadDriver.java
D:\Program Files\Java\jdk1.5.0_03\bin>java LoadDriver
Exception in thread "main" java.lang.NoClassDefFoundError: org/aspectj/lang/Sign
ature
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at LoadDriver.main(LoadDriver.java:20)
D:\Program Files\Java\jdk1.5.0_03\bin>
I place mysql.jar in
- D:\Program Files\Java\jdk1.5.0_03\jre\lib\ext
- D:\Program Files\Java\jdk1.5.0_03\lib
- D:\Program Files\Java\jdk1.5.0_03\jre\lib
and i make classpath to D:\Program Files\Java\jdk1.5.0_03\bin;D:\Program Files\Java\jdk1.5.0_03\jre\lib\ext\
but it still doesn't work
What must I do ?
Thx 4 your replyHello!
I'm getting this same error message and i followed the code example as close as i could:
Thanks for any help on this!
bk
set oldpath=%PATH%
set JAVA_HOME=C:\jdk1.5.0_02
set ANT_HOME=C:\ANT\apache-ant-1.6.5
set PATH=C:\jdk1.5.0_02\bin;%ANT_HOME%\bin
set CLASSPATH=.;C:\jdk1.5.0_02\lib;C:\MYSQL\mysql-connector-java-3.1.10\src\com\;C:\MYSQL\mysql-connector-java-3.1.10\src\org\;C:\MYSQL\mysql-connector-java-3.1.10\mysql-connector-java-3.1.10-bin-g.jar;
http://www.developer.com/java/data/article.php/3417381#Critical_steps_in_using_JDBC
import java.sql.*;
public class Jdbc11 {
public static void main(String args[]){
System.out.println(
"Copyright 2004, R.G.Baldwin");
try {
Statement stmt;
//Register the JDBC driver for MySQL.
Class.forName("com.mysql.jdbc.Driver");
//Define URL of database server for
// database named mysql on the localhost
// with the default port number 3306.
String url =
"jdbc:mysql://localhost:3306/mysql";
//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 =
DriverManager.getConnection(
url,"root", "");
//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
stmt.executeUpdate(
"CREATE DATABASE JunkDB");
//Register a new user named auser on the
// database named JunkDB with a password
// drowssap enabling several different
// privileges.
stmt.executeUpdate(
"GRANT SELECT,INSERT,UPDATE,DELETE," +
"CREATE,DROP " +
"ON JunkDB.* TO 'auser'@'localhost' " +
"IDENTIFIED BY 'drowssap';");
con.close();
}catch( Exception e ) {
e.printStackTrace();
}//end catch
}//end main
}//end class Jdbc11
Exception in thread "main" java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
Maybe you are looking for
-
Centralized Dunning run and local printing requirement
Hello SAP FICO experts, I have a requirement at my client as follows. To schedule dunning run centrally for all company codes or selected company codes periodically and automatically. Ability to print dunning letters in local offices in each country
-
Install gcc 3.2.3 on Solaris 9
Have installed Sol 2.9 on a SparcStation 4, now trying to get GCC onto it. However, the "make bootstrap" command from the html documentation does not work. It asks for a valid copy of 'cc' which I do not have, which was the reason I am trying to inst
-
How to supply username and password for consuming webservice in BizTalk Adaptor?
While I hit the web service directly , I am able get response from that service, it asked for username and password, after that it processed the request and gave expected output. I am trying to consume the same web service (https) from BizTalk orches
-
GX 620 barebone - SCM - Multimedia button not working correctly.
I just installed Win 7 Pro x64 RTM from msdnaa. Everything works great so far, except for the music multimedia buttons (back, stop, play/pauses, etc.) They only work if I have the music app selected, otherwise it does nothing. Under Vista sp2 this fe
-
Magnetic Lasso tool makes screen go black
When I am using the magnetic lasso, the screen keeps going black. Any suggestions?