Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet connecting to a database dynamically
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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



Advertisement
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 Tutorials/Questions & Answers:
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
Advertisements
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 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 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 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
Dynamically Update textbox from database
Dynamically Update textbox from database  I have a database as shown below.(database created using SQL Server 2005) name : george,simon address... to that typed value from database has to be displayed in another text box
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
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
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 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
Connecting to a MySQL Database in Java
Connecting to a MySQL Database in Java   ... on connecting to a MySQL database, after going through this program you... classes and APIs with which we can make use of the database as we like. 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
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, how to dynamically increase size of list box in javascript when elements retrieving from database.. That is whenever I
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 Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java
How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java  How To Store Multilple Images In MySQL database dynamically with image uploader
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
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
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  selDept.jsp <%@page import="java.sql.*"%> <... the database but when we give same department name it is repeting i.e if we enter
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
Advertisements
 

 

 

DMCA.com