aspose file tools*
The moose likes JDBC and the fly likes connectivity with my sql without connecting to existing database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "connectivity with my sql without connecting to existing database" Watch "connectivity with my sql without connecting to existing database" New topic
Author

connectivity with my sql without connecting to existing database

nehaa jain
Greenhorn

Joined: Aug 26, 2009
Posts: 2

please help me....
i'm planning to build a project "user friendly my sql"
i.e user don't need to write statements in sql..he will have to click on buttons nd he is done..
like he will click on button "create table"... then it will ask table name and atrtributes etc...
but i have a problem in connectivity..
how to login in to my sql?..
i want to connect to sql server... bt there is no specific database to which i want to connect.. as user will bulid his own database...
can anyone tell me the code for it....???
this would be my final year project that i'm starting so i need your help guys...!!!
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Welcome to JR.
First, what you really need is an introduction to JDBC and the great start will be the Sun Tutorial
Next, you have to learn that each Database has some technique to get connection through Java and also depned upon the type of driver used.So you have to create the connection string as per the Database selected and get the connection, once the connection establish, it mens you can ping to the database and next you can ask user for tables, etc.

Also look at this FAQ, this will help.
http://faq.javaranch.com/java/JdbcFaq

HTH

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
nehaa jain
Greenhorn

Joined: Aug 26, 2009
Posts: 2
thankyou sir..
still i have doubt...
i know how to connect to a database...using jdbc odbc driver..please read following line.....
Class.forName("com.mysql.jdbc.Driver");
Connection conn =DriverManager.getConnection("jdbc:mysql://localhost:3306/db2","root","prakki");
Statement stat1=conn.createStatement();
these are the lines which i wrote to connet with database db2...
bt i want to know that what should i do if every user will create his own database after login ??

Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

nehaa jain wrote:thankyou sir..

Don't called me Sir, (It felt like I got some white hair on my head)
nehaa jain wrote:bt i want to know that what should i do if every user will create his own database after login ??

Let them create as many database/schema as they want to create. You don't have to worry about that.

Here is some steps I can suggests:
1. Ask User the the database vendor (like MySQL, SQL Server, etc), once he selected you load the driver for that database
2. Next ask for the database name.
3. Create the connection string using the above information.
4. Once the successful connection establish, then you can create table, SP, add/delete/update rows, etc.
James Ward
Ranch Hand

Joined: Apr 27, 2003
Posts: 263
Another option can be - instead of dealing with these different database vendors - MySQL, SQL Server, Sybase, Oracle etc; you could embed a Java Database in your application - Apache Derby ( http://db.apache.org/derby/ ) can be used.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: connectivity with my sql without connecting to existing database