odbc « mysql « Java Database Q&A

Home
Java Database Q&A
1.Blob
2.cassandra
3.column
4.Connection
5.Cursor
6.dao
7.Data Type
8.Database
9.Database Product
10.DataSource
11.Date
12.db2
13.derby
14.Development
15.Driver
16.Exception
17.file
18.hadoop
19.hbase
20.hsqldb
21.ibatis
22.JDBC
23.memcached
24.mongodb
25.MS Access
26.mysql
27.ODBC
28.Operation
29.oracle
30.postgresql
31.Record
32.result
33.Resultset
34.Schema
35.SQL
36.sqlite
37.SQLserver
38.Statement
39.stored procedure
40.sybase
41.Table
42.Transaction
43.Trigger
Java Database Q&A » mysql » odbc 

1. Java not giving Error!    stackoverflow.com

Here is my code - i am simply checking my MySQL database connection.
But first i have compiled and run the program successfully. but then i have commented the line Class.forName .
Still ...

2. ODBC - mysql connectivity    coderanch.com

import java.io.*; import java.sql.*; import java.util.*; class Testmin { Statement stmt=null; Connection cn=null; private String query; String s; public Testmin() { System.out.println("Enter a date:\n"); Scanner sc= new Scanner(System.in); s=sc.next(); java.sql.Date d1=java.sql.Date.valueOf(s); System.out.println(d1); try { Class.forName("com.mysql.jdbc.Driver"); cn=DriverManager.getConnection("jdbc:mysql://jeyasri-desktop:3306/prog","root","123456"); if(cn!=null) { stmt=cn.createStatement(); query="insert into Date values("+d1+");"; stmt.executeUpdate(query); } else System.out.println("Not connected"); } catch(SQLException sqle) { System.out.println(sqle); } catch(ClassNotFoundException cnfe) { System.out.println(cnfe); } } } ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.