Home Answers Viewqa JSP-Servlet error in accessing database

 
 


tanushri biswas
error in accessing database
1 Answer(s)      4 years and 4 months ago
Posted in : JSP-Servlet

View Answers

February 12, 2009 at 6:16 AM


Hi friend,

Code to help in solving the problem :

import java.sql.*;

public class MysqlConnect{
public static void main(String[] args) {
System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "jdbctutorial";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
System.out.println("Connected to the database");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Thanks









Related Pages:
error in accessing database - JSP-Servlet
error in accessing database  hiiii im tanushri im tryng to connect my database to the servlet i hv succeeded in connectivity but im stuck to nother error called Got minus one from read call although i hv feeded data to my
Problem in accessing data from Database
Problem in accessing data from Database  hi..... i'm making a project on servlet and jsp with ms access 2007 at the backend. One field in my database... the result is not displayed.......the error states......"The message log is Null". Can
Accessing database with JDBC via Java
Accessing database with JDBC via Java  How to access a database with JDBC via Java application?   Accessing database with JDBC through Java JDBC Example to access Database import java.sql.*; public class JdbcConnect
Accessing Database using EJB
Accessing Database using EJB       This is a simple EJB Application that access the database. Just go through the EJB example given below to find out the steps involved in accessing
Accessing Database from servlets through JDBC!
Accessing Access Database From Servlet    This article shows you how to access database from servlets... Access Database as backend and Sun's JDBC-ODBC bridge to connect to access
Accessing Database using EJB
.style1 { color: #000000; } Accessing Database...; This is a simple EJB Application that access the database. Just go through the EJB example given below to find out the steps involved in accessing Database. Creating
accessing ms access through jsp
accessing ms access through jsp  i have 3 tables in my database employee,project,task if i put employee id the search field .i should get details from other table what all queries should i use in servlet file and i am using
getting error while inserting values in database
) { out.println("An Error Had occurred while accessing the database...getting error while inserting values in database  AddUser.java..."); if (envContext == null)throw new Exception("Error: No Context
Accessing database from JSP
Accessing database from JSP   ... or Accessing data from database: This is done using following code :- stmt... going to discuss the connectivity from MYSQL database with JSP.we take a example
Accessing Jqxgrid data in Controller layer using JSP
Accessing Jqxgrid data in Controller layer using JSP  I am using... it into the database. On click of some button, the data displaying in jqxgrid is to be inserted into the database. Atleast if I am able to get the data from Jqxgrid
error log and send Database
error log and send Database  hi my requirement is validate xml and xsd in java.If there is an errors then i will log error and store into error table. so plz if any one knows send code urgent. error table details
Database error - WebSevices
Database error  Hello, How i connect my database file& tables to Zend library file Using PHP language. In which library file i should change that code. Any one know the exact changes. Tell me.   http
Database Error - Hibernate
Database Error  Hi, I am working with Struts 1.2---- AJAX-----Hibernate 3.0 --- MySQL 5.0. At the time of inserting/fetching from Database... exceeded; try restarting transaction That means the database becomes locked. Can
Applet to database error - Applet
Applet to database error  Hi... I had an application where i need to connect to the database for the values to display in the applet.... Following... necessary for finding the error... as itz only drawing strings or lines
java database error - JDBC
java database error  hi all i am writing one swing application where i want to insert data into database(MS-Access) but dont know how to do... the following code to insert the data into MS-Access database: import java.sql.
connection database error
connection database error  import java.awt.EventQueue; // import packages import java.awt.event.ActionEvent; import java.awt.event.ActionListener...;which type of error occurs? Specify it. Is NWIND is your dsn
error oracle database connection?
error oracle database connection?  hi now i am trying to connect oracle database and also insert my data into table, but it's not working.. I created one user registration form. when i give values in the form, i want stored data
Oracle Database error - JDBC
Oracle Database error   String query11 = "SELECT product_code, product_quantity, price FROM o"+orderid; ResultSet rs11 = stmt.executeQuery(query11); while(rs11.next()){ product_code[j
Accessing Database from servlets through JDBC!
resources(such as open files or database connections
database
database  im doing my project in netbeans swings...wn a user wants to create a database from the gui...i want to display an error msg if a database with that name already exists and if it does not exist new database should
Database
Database  In MYSQL database i m given as the email id as the char but i enter the email id it gives manually error.how can i recover that error   For email, use the data type varchar
Accessing MS ACCESS databse using a HTML webpage [created using Javascript]
Accessing MS ACCESS databse using a HTML webpage [created using Javascript]  HI team, This is Srinivas, and I have a query and i explained here... I have to save some datas in an MS ACCESS database file [*.mdb], after
database
, dob date default NULL, PRIMARY KEY (id) ); i got error...; Have you run this query directly into the Mysql database? Here it works properly.   Have you run this query directly into the Mysql database? Here
Applet Error - Applet
an applet to get the database values into the applet when i clicked a line... It works... are returning when i'm accessing the server from my local system  Hi Friend... the error... as itz only drawing strings or lines
Display error message if data is already inserted in database
Display error message if data is already inserted in database   Display error message if data is already inserted in database Pls help me Thanks
Accessing Databases Using Java and JDBC
Accessing Database using Java and JDBC       Accessing Database using Java and JDBC Database plays... develop and example to access the database using Java and JDBC. For this, firstly
programming error
programming error  I got an error when i did the following program the prg. is to "select the name from database when the age is given for the respective name" error i got is:SQL exception please give me the solution by providing
PHP SQL IF Statement
accessing the data from table in mysql database. In this example we create a connection from database table using mysql_connect("hostName", "userName", "Password"). After the connection created we choose database
PHP SQL IF Statement
the 'if' statement when accessing the data from mysql database table in php.  In this example we create a connection from database table using mysql_connect("... created we choose database by mysql_select_db("databaseName"
runtime error
runtime error  still i am getting runtime error as:the specified dsn...;Hi, This error is related to some OS related problem. "dsn contains... have to download Microsoft Access Database Engine 2010 Redistributable
accessing xml using java
accessing xml using java  I need to retrieve some elements in xml file using java   Hi Friend, Please visit the following links: http://www.roseindia.net/xml/Listingnode.shtml http://www.roseindia.net/xml/getting
Accessing webcam in jsp
Accessing webcam in jsp  Hi Friends, I have to access the webcam through jsp and display the snap in same jsp taken after a click. I am using java media framework but i am not able to detect the device using CaptureDeviceManager
Accessing Web-cam
Accessing Web-cam  I am giving options to upload a photo to the user.. options are: 1st) upload a photo from ur hard drive. 2nd) upload a photo from web-cam. Then how to implement 2nd option using jsp ....can any one
Servlet error
Servlet error  In netbeans6.9 how can we deploy our servlet in my project i design servlet to receive the data through html pages and design database also but unable to do with xml files what we can change in sun-web.xml
error come
error come  com.techi.bean.Employee cannot be cast... each attribute  Here is the code that retrieve the values from database... database. 1)EmpBean.java: package form; import java.sql.*; import java.util.
error - JDBC
to the database"); conn.close(); System.out.println("Disconnected from database"); } catch (Exception e) { e.printStackTrace
jQuery auto complete through database using JSP shows error
jQuery auto complete through database using JSP shows error  The tutorial on jQuery titled "jQuery auto complete through database using JSP" shows error on browser when I try to select the one in the dropdown. Please help
inserting data from radio buttons to database-ERROR - JSP-Servlet
inserting data from radio buttons to database-ERROR  hi, i have already changed the option field of table question. the code which you give me has... it in the code. but still i am getting the error in the update query. please provide
PROBLEM IN ACCESSING JSTL - JSP-Servlet
PROBLEM IN ACCESSING JSTL   hii i m vikram ... i am using jsp application with tomcat 4.1 .and i want to use JSTL in my jsp page ...so how can i use JSTL in my page .. and i install jakaerta-taglibs-standard-1.1.2 in directory
error in uploading image from jsp to oracle 10g database
try to insert into the image into the database i got the above error please advice how to get rid of error   JSP upload image in Mysql database...error in uploading image from jsp to oracle 10g database  
Database Connectivity
Database Connectivity  I tried to establish database connection...:\Glass Fish\glassfish-v2ur1\javadb\lib\sqljdbc.jar) it shows me error as " An error has occurred Class name is wrong or classpath is not set
error in driver connection
error in driver connection  String driver = "org.gjt.mm.mysql.Driver"; Class.forName(driver).newInstance(); //error at this line...; but this is the syntax for aceesing database in jsp
database query
database query  create table file1 ( file_id int , file_data text ); i'm unable to create this table and the error is invalid type text. plz help me
Error - Development process
Error  Sir ,The Bus Time Table Provided by u there is Following error Error Code 1 Submit Failed plz Give Me Solution.  Hi Friend, It seems that you haven't create a table in the database or there may be a problem
retrive record from the text field and insert into to database
occurred while accessing the database"); out.println("<HR>...;the following code is inserting values in the my sql database but i want to insert the data into oracle database , i want what changes i have to make
Login Form
database, as a register user you are always asked for the login to accessing data. E-mail's login are very  good example...(); //Write jdbc code to validate the user against database
Error in connecting to the mySQL database in TOMCAT using more than one PC (database connection pooling)
Error in connecting to the mySQL database in TOMCAT using more than one PC (database connection pooling)  how do i implement connection pooling... the same application/database, I get a java.lang.NullPointer Exception. Can you help
Getting Error - Development process
Getting Error   Hi , i am getting error while executing this code. I just want to store date in to database. Dont mistake me for repeated questions. java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Number