Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JDBC and Relational Databases
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Eclipse Collections Categorically: Level up your programming game
this week in the
Open Source Projects
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Ron McLeod
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
JDBC and Relational Databases
Create DB2 database
soni agg
Greenhorn
Posts: 3
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi
I want to create a database in DB2 dynamically through
java
code and
jdbc
type 4 driver for DB2. I used the following code:
import java.sql.*; import java.io.*; public class DBTry { public static void main(String s[]) throws IOException, SQLException { Connection conCopyTo = null; try { //retreive connection for DB2 String url = "jdbc:db2://localhost:50000/default"; String userId = "sajal"; String pwd = "admin"; Class.forName("com.ibm.db2.jcc.DB2Driver"); conCopyTo = DriverManager.getConnection(url, userId, pwd); System.out.println("ConvertAcc2DB2:ConCopyTo:"+conCopyTo); } catch(Exception e) { System.out.println(e); } try { PreparedStatement psc=conCopyTo.prepareStatement("Create database DBtry"); int updatec=psc.executeUpdate(); System.out.println("Database Created!updatec"+updatec); } catch(Exception e) { System.out.println("ConvertAcc2DB2:createDatabase:PreparedStatementException:"+e); } } }
But the output shows following exception:
ConvertAcc2DB2:ConCopyTo:com.ibm.db2.jcc.b.b@19134f4 ConvertAcc2DB2:createDatabase:PreparedStatementException:com.ibm.db2.jcc.c.SqlEx ception: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: database;Creat e ;TABLESPACE
Bhaskar GR
Greenhorn
Posts: 28
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
It is problem in Prepared statement
soni agg
Greenhorn
Posts: 3
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
can you tell what problem can you find in my prepared statement as you said ?
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
java.sql.SQLException: No suitable driver
problem connecting to postgres 8.2.3
What is wrong here
error in compling --can anyone help
Database Connection
More...