here is the code.. but it is not working.. why?

import java.sql.*;
public class Connect{
  public static void main (String[] args){
           Connection conn = null;
           try{
             String userName ="testuser";
             String password ="testpass";
             String url = "jdbc:mysql:/localhost:3306/test";
             Class.forName("com.mysql.jdbc.Driver").newInstance();
             conn = DriverManager.getConnection (url,userName,password);
             System.out.println ("Database connection established");
           }
           catch(Exception e){
               System.err.println("Cannot connect to database server");
           }
           finally{
               if(conn != null){
                   try{
                     conn.close ();
                     System.out.println ("Database connection terminated");
                      }
                     catch (Exception e) { /* connection close error occurs */ }
             }
          }
       }
   }

Please use Code tags, cause if you care about getting the solution, then you should also care about the forum rules.
And one major problem, you have not mentioned the problem, is the program compiling, if not what errors are you getting, if its compiling what is the output you are getting and what do you wish to get ???

Not working can mean a lot of things, especially with relational databases.

Not working as in, you are running a version of Java that may or may not initially support jdbc (versions before 6 I believe) ?

Not working as in, the program wont compile?

Not working as in, the program doesn't work the way you want it to?

So much for telling us "here is the code.. but it is not working.. why?" - please be more elaborate!

Hi

My contribution is to create to-do list and stored in file it may be txt file or any other file in any format or DB(local) for stand alone applications. for this, i have written the code for both stored in file as well as stored in DB for this to achieve i used swings and mysql.

here i have attached the code see the attachments please..

im using netbeans IDE

DB is connected and the code is also run

My question is:

can anyone complete this project for all possibilities add, delete, sort, search , view in both (file and MYSQL DB) or anyone (file or MYSQL DB)

i need urgent please

if i click the add button it wants to stored in DB (or) file or both.

complete the part please

reply to me as soon as possible

it is not completely done

can anyone help to complete the code and revert back to <email snipped>
Regards
Kevin

commented: No one is going to write this for you. That is not the purpose of these forums. -2

No. We are not going to do your (home)work for you. If you have a specific question ask it, and we will attempt to answer it for you, but we are not, as already said, going to do it for you.

Hi

What my question is code is run

if i click that add new and save button then it is not work on that code

how can i do

Let me know

Regards
Kevin

Define "not work".

Define "not work".

i want to stored the created to-do list in file or DB

here i have written the code to stored the to-do list in file.

If i click that "add new" button or "save" button then it wants to stored in file but it is not stored.

at the same time how can i write the code to store the to-do list in mysql DB

Regards
Kevin

can anyone help me

i have written the programs with swings

but it is not properly work

i mean if i click that "add new" button the it will go to stored in file but it is not stored in file and same like as "save" button and i want to view the data in the file

how can i?


help me

Regards
Kevin

commented: Do not create duplicate threads +0

Do not make duplicate threads. This is the third thread with a similar topic, thats why I gave you the negative mark. You did not even care to respond to the people who tried to help you in the first thread

commented: Saved me the trouble =P +3

Do not make duplicate threads. This is the third thread with a similar topic, thats why I gave you the negative mark. You did not even care to respond to the people who tried to help you in the first thread

Hi

sorry for that to create an duplicate threads.

I didnt get any positive reply from that previous thread thats why

Regards
Kevin

Hi

sorry for that to create an duplicate threads.

I didnt get any positive reply from that previous thread thats why

Regards
Kevin

Because you haven't provided either any meaningful information, nor shown any effort.

Simply posted a partially complete code and said "do the rest of this for me".

Hi

sorry for that to create an duplicate threads.

I didnt get any positive reply from that previous thread thats why

Regards
Kevin

No one is going to give you some sort of magic bullet to solve all the problems in your code, you need to do first what is asked of you, if you expect to find the solution.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.