Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connectivity with my sql without connecting to existing database

 
nehaa jain
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
nehaa jain
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic