Home Answers Viewqa JSP-Servlet connecting to a database dynamically

 
 


soni
connecting to a database dynamically
1 Answer(s)      4 years and a month ago
Posted in : JSP-Servlet

View Answers

April 28, 2009 at 12:18 PM


Hi Friend,

Your code haven't found the Data Source Name(DSN) of the connection. Therefore it throws NullPointerException.

Use the following code where 'access' is my data source name:

<%@ page import ="java.io.*"%>
<%@ page import ="javax.servlet.*"%>
<%@ page import ="javax.servlet.http.*"%>
<%@ page import ="java.sql.*"%>
<% Connection conn=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn =DriverManager.getConnection("jdbc:odbc:access","","");

}
catch(Exception ex)
{
ex.printStackTrace();
}

Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("select * from subject");
while(rs.next())
{
out.println(rs.getString("name"));
}
%>
Thanks









Related Pages:
connecting to a database dynamically - JSP-Servlet
connecting to a database dynamically   abc.html :- abc.jsp :- Above code gives the following... with database dynamically. Plz debug the code and explain the reasons for the exception
Connecting to a database through the Proxy.
Connecting to a database through the Proxy.  Connecting to a database through the Proxy I want to connect to remote database using a program that is running in the local network behind the proxy. Is that possible
connecting with database - Struts
connecting with database  I am creating an application where when jsp page is displayed, it contains the combo box where data is populated from the database.it has 3 buttons and the functionality for all buttons is different
connecting to database - Struts
connecting to database  Hi I am having problems with connection to MS SQL Server 2005 database. My first is what do i write in struts... information via the database in my web page. Thanks Tayo  Hi friend
Connecting code of reset password to database
Connecting code of reset password to database  connecting code of reset password to database
Connecting to MYSQL Database in Java
Connecting to MYSQL Database in Java  I've tried executing the code... to the database"); conn.close(); System.out.println("Disconnected from database"); } catch (Exception e) { System.out.println("Error
Connecting JTable to database - JDBC
Connecting JTable to database  Hi.. I am doing a project on Project Management System for which i created the user interfaces.. I have a user... to store this JTable content in my database table.. This is a very important
connecting databases
connecting databases  I need to connect mysql on 2 or more remote pc'c. how can i giv the ip address for 2 or more systems. is it possible to connect to the required systems by user specifying the database and table name my
connecting to access database
connecting to access database  print("code sample");Hi I Write java... this there is no error but my data is not going to my Acess Database. There is working... Access Driver(*.mdb) Select database name and Create the DSN name (e.g access
Connecting Oracle database with struts - Struts
Connecting Oracle database with struts  Can anyone please provide me some solutions on Connection between Oracle database and struts
Problems connecting to a database. Java/SQLite
Problems connecting to a database. Java/SQLite  `print("try { con = DriverManager.getConnection("jdbc:sqlite:db/Freepark.sqlite"); } catch... on an SQL database but i am having problems connecting to it, I think the problem
code for connecting reset password code to database.
code for connecting reset password code to database.  code for connecting reset password code to database.   Hello Friend, Do you want to change your password and update the password to database
Connecting to Database from a hyperlink in JSP - JSP-Servlet
Connecting to Database from a hyperlink in JSP  How can I connect to database by clicking on a hyperlink in a JSP Page.Can you please give me sample... which is connect to database using jdbc database
jsp -sevlet connecting to database using dropdown
jsp -sevlet connecting to database using dropdown  How can I get my dropdown list from oracle database and then submit it to another table in JSP. I... to the database and fetches an array of strings from a database table and then sends
Connecting to the Database Using JDBC and Pure Java driver
Connecting to the Database JDBC Driver In our search engine we are using MySQL database server and MM.MySQL Driver for connecting our application to the database. MM.MySQL Driver
Switching dynamically between database schemas - JDBC
Switching dynamically between database schemas   I am working on a project which requires to switch between database schemas dynamically. Am using MySql as my database and am coding using core and advanced java. I have been
Dynamically adding textbox and labels
Dynamically adding textbox and labels  Sir, In my application I want to insert texbox and labels dynamically and want to insert database field value in that generated label. Plz help me, Thanks in advance
Connecting jboss with sql 2005 - Struts
Connecting jboss with sql 2005  Hai, i have project that was developed in struts,backed is sqlserver 2005 and and i am using jboss. I want to connect another database (sqlserver 2005) with my project.could u please help me
Store values of dynamically generated textboxes into database
Store values of dynamically generated textboxes into database   I'm trying to create a form where the user gives number to generate textboxes. when... it to be saved in MYSQL database. Anybody please help me
connecting servlet to db2 - JSP-Servlet
connecting servlet to db2  Hello sir, Iam new to db2.so I would like... the configuration we need to be done before connecting to the db2(such as what path we have to set and all).  If u are using the oracle Database 9i
connecting jsp to mysql - JSP-Servlet
connecting jsp to mysql  Hi, i am working on 'Web application development' project that uses JSP, MySQL and tomcat.i am not able to connect to the mysql database through jsp. After downloading the mysql-connector-java-5.0  
doubt in connecting to mysql in flex - XML
doubt in connecting to mysql in flex  The ?Create application from database? is a Flex 3 feature that enable you to create simple applications in few... of all you have tosetupyourMySql datasource by creating a database and a table
doubt in connecting mysql in flex - XML
doubt in connecting mysql in flex  The ?Create application from database? is a Flex 3 feature that enable you to create simple applications in few... of all you have tosetupyourMySql datasource by creating a database and a table
java connecting to oracle db - JDBC
java connecting to oracle db  how to connect oracle data base...) Connect to database:*********** a) If you are using oracle oci driver,you have... is the host,3306 is the port, roseindia is the database and root is the username and password
Create XMl dynamically - XML
Create XMl dynamically  Hi I am retreiving the list from database which i need to display in an XML file with some nodes How can I do
Connecting to MySQL database and retrieving and displaying data in JSP page
Connecting to MySQL database and retrieving and displaying data in JSP page...;org.gjt.mm.mysql.Driver").newInstance(); Connecting to your database To connect...; This tutorial shows you how to connect to MySQL database and retrieve the data
how to add data dynamically from database into a dropdown list in a jsp
how to add data dynamically from database into a dropdown list in a jsp ... get dynamically from the database and whenever a new person has registered his... in storing them into the database,this registration form contains name
Connecting to a MySQL Database in Java
Connecting to a MySQL Database in Java   ... data form MySQL database. We are going to make a program on connecting to a MySQL... and APIs with which we can make use of the database as we like. Database plays
java code for threading example for connecting data base
java code for threading example for connecting data base  Write a program that has two threads First thread queries the database and fetches all the employee records from the emp table. Stores the employee objects
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
How to add dynamically rows into database ?Need help pls
How to add dynamically rows into database ?Need help pls  Hi everyone, I really have a problem of insert multiple rows into the database.Now i can...')"; $result = mysqli_query($link, $query) or die('Error querying database
how to insert list box in java script dynamically and elements retrieving from database like oracle
how to insert list box in java script dynamically and elements retrieving from database like oracle  hi all, how can i insert elements into java script list box retrieving from Database. whenever I insert any element in the Db
how to insert list box in java script dynamically and elements retrieving from database like oracle
how to insert list box in java script dynamically and elements retrieving from database like oracle  Hi, how to dynamically increase size of list box in javascript when elements retrieving from database.. That is whenever I
add text box and select list dynamically and get its value to store it into database using jsp request parameter
add text box and select list dynamically and get its value to store it into database using jsp request parameter  its very helpful when you have only dynamically added text field but want code to retrive value of dynamically
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database
Null pointer exceptation-Java Servlet web application,Problem connecting... system won't be able to connect to database in pooling environment. i try follow some.../database_name" auth="Container" maxActive="100" maxIdle="30" maxWait
How to display gridview details to labels dynamically?
How to display gridview details to labels dynamically?  I am using SQLDataSource to connect to MySQL. I have a gridview that retrieves information from MySQL database based on a selected id(dropdownlist). I need to display
how to access element added via javascript dynamically using jsp code
how to access element added via javascript dynamically using jsp code ... javascript dynamically using the jsp code. i am adding empty records on .jsp page... not able to access these dynamically added textboxes values from my jsp code
data should not repeat in the drop down list when it is loading dynamically from database
the data dynamically for database but my problem is in the list the same...data should not repeat in the drop down list when it is loading dynamically from database  selDept.jsp <%@page import="java.sql.*"%>
data should not repeat in the drop down list when it is loading dynamically from database
data should not repeat in the drop down list when it is loading dynamically from database  hi friends the below code is working correctly for loading the data dynamically from the data base but my problem is it is retrieving
data should not repeat in the drop down list when it is loading dynamically from database
data should not repeat in the drop down list when it is loading dynamically from database  selDept.jsp <%@page import="java.sql.*"%> <... the database but when we give same department name it is repeting i.e if we enter
connecting to timesten in web application
connecting to timesten in web application  Please give me the steps connecting to timesten in web application. Am using jsp
Dynamically update the Label & set Bounds constant between 2 Label(Thread)
in Dynamically update the label. when i m changing the the value in database , its dynamically not updated prblem is jPanel.add(label11); and also not setting...Dynamically update the Label & set Bounds constant between 2 Label(Thread
Dynamically update the Label & set Bounds constant between 2 Label(Thread)
in Dynamically update the label. when i m changing the the value in database , its dynamically not updated prblem is jPanel.add(label11); and also not setting...Dynamically update the Label & set Bounds constant between 2 Label(Thread
Dynamically update the Label & set Bounds constant between 2 Label(Thread)
in Dynamically update the label. when i m changing the the value in database , its dynamically not updated prblem is jPanel.add(label11); and also not setting...Dynamically update the Label & set Bounds constant between 2 Label(Thread
java connecting frames
java connecting frames  how to connect one frame to another frame by using awt or swings?`print("code sample
JDBC access database
JDBC access database       JDBC is a Java Database Connectivity. The JDBC Connectivity provides API classes and interfaces for connecting the front end in Java application with database connections
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.