Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8718679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:36:15+00:00 2026-06-13T06:36:15+00:00

I am having problem in connecting to mysql database when I am using this

  • 0

I am having problem in connecting to mysql database when I am using this code.I have already checked that port number is 3128.So there is no issue about that.I checked it and I think problem is in

connection= DriverManager.getConnection("jdbc:mysql://localhost:3128/gcc","root", "root");

There is no error when compiling.Can someone help me with this?

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.sql.*;
//import java.net.*;

public class Main extends Applet implements ActionListener
{
 TextArea tarea;
 Button bsubmit;

 public void init()
 {
  setBackground(new Color(0,0,0));
  setForeground(Color.white);

  Label l1=new Label("Write your code : ");
  l1.setFont(new Font("lucida console",Font.PLAIN,25));
  l1.setSize(200,30);

  tarea=new TextArea();
  tarea.setFont(new Font("lucida console",Font.PLAIN,18));
  tarea.setForeground(new Color(0,0,0));
  tarea.setSize(600,250);

  bsubmit=new Button("Submit");
  bsubmit.setFont(new Font("lucida console",Font.PLAIN,15));
  bsubmit.setBackground(new Color(255,255,255));
  bsubmit.setForeground(new Color(0,0,0));
  bsubmit.setSize(100,30);

  add(l1);
  add(tarea);
  add(bsubmit);

  setLayout(null);
  l1.setLocation(40,40);
  tarea.setLocation(40,100);
  bsubmit.setLocation(40,400);

  bsubmit.addActionListener(this);
 }

 public void actionPerformed(ActionEvent ae)
 {
  if(ae.getSource()==bsubmit)
  {
   Connection connection=null;
   try 
   {
    Class.forName("com.mysql.jdbc.Driver");
    connection= DriverManager.getConnection("jdbc:mysql://localhost:3128/gcc","root", "root");
    Statement stmt = connection.createStatement();
    stmt.executeUpdate("CREATE TABLE test2 (code VARCHAR(254))");
   } 
   catch (Exception e) {}
  }  
 }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:36:16+00:00Added an answer on June 13, 2026 at 6:36 am

    Java database drivers are the worst thing. I remember, I had my first JDBC driver (or let’s say: a working transaction;) to be installed within “only” 2 days, and I know a guy who had two weeks, lol.

    In most of the time the very last issue is a SQL problem. Because you need to give the rights to the user as “username”@”IP”. You find the user information in the database information_schema in the table user_privileges. There exist enough tutorials how to handle them, but I like ‘username’@’%’ to get all privileges in a test environment. smile

    This may help you: http://dev.mysql.com/doc/refman/5.1/de/adding-users.html

    Yeah, those damn SQL rights… ;D

    @Luiggi: That’s certainly no silly question! I had hours to find that out!! I mean, which beginner knows that the Java sql classes are only xxxxxxx interfaces with no implemented code?! %D

    EDIT

    And anyway:

    Class.forName("...driverblabla...");
    

    Does this code line look like Java? Nooo, its a xxxxxx compiler hack or whatever! But it works, it really DOES something!!

    Oh, but for certain driver implementations this won’t work, you need this:

    Class.forName("...driverblabla...").newInstance();
    

    LMAO!

    @Abhinav: Add this line above your getConnection-line:

    Class.forName("com.mysql.jdbc.driver").newInstance();
    

    And don’t think one second about what it exactly does (I know it, but…let’s screw it 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[Updated below] I am having a problem connecting to a MySQL database using a
I am having a problem with a website, connecting to a MySQL database using
I'm having a strange problem connecting via remote to MySQL. This is an internal
I am having a problem with PHP from that adds data to MYSQL database
Im having problem in my UIscrollView ,this is what I have done: Whenever a
I am currently having a problem selecting a certain item from a mySQL database.
I am having this big database on one MSSQL server that contains data indexed
I have an application that uses Hibernate to connect to my MySQL database. I'm
im having a problem with fetching data from Mysql 5.1 using JDBC (mysql-connector-java-5.1.18-bin.jar). my
I am new to OOP having this code and am having a problem creating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.