unable to connect database in java
Hello Everyone! i was trying to connect database with my application by using java but i am unable to connect...
i was using this code....
try
{
Driver d=(Driver)Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
c=DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)};DBQ=E:/Final Project/Lalit.mdb");
st=c.createStatement();
}catch(Exception e){e.printStackTrace();}
And i am getting this error
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not fou
nd and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6956)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7113)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3072)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:3
23)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:243)
at test.(test.java:14)
at test.main(test.java:23)
pls help me to solve this.....
View Answers
March 23, 2012 at 11:39 AM
Follow these steps:
1)Go to the start->Control Panel->Administrative Tools-> data sources.
2)Click Add button and select the driver Microsoft Access Driver(*.mdb).
3)After selecting the driver, click finish button.
4)Then give Data Source Name and click ok button.
5)Your DSN will get created.
6) Restart your compiler and compile your java code.
For Inserting Data:
import java.sql.*;
class AccessDatabase{
public static void main(String[] args){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:student");
Statement st=con.createStatement();
String name="roseindia";
String address="delhi";
int i=st.executeUpdate("insert into user(name,address) values('"+name+"','"+address+"')");
System.out.println("Row is added");
}
catch(Exception e){
System.out.println(e);
}
}
}
Related Tutorials/Questions & Answers:
unable to connect database in javaunable to
connect database in java Hello Everyone! i was trying to
connect database with my application by using
java but i am
unable to
connect...
i was using this code....
try
{
Driver d=(Driver)Class.forName
unable to connect database in javaunable to
connect database in java Hello Everyone! i was trying to
connect database with my application by using
java but i am
unable to
connect... created.
6) Restart your compiler and compile your
java code.
For Inserting Data
Advertisements
unable to connect to server - JSP-Servletunable to
connect to server thank you for the program code for inserting and reteriving the image but i am
unable to deploy these two programs in weblogic/apache servers can any one help me how to do this ? Hi Friend
TO connect multiple databaseTO
connect multiple database How to
connect several
database from a single application in
java depending upon the user input it will
connect to that
database Unable to store the image into databaseUnable to store the image into database Hello,
I have created below program and program is throwing FileNotFound exception when I pressed the submit...);
}
Hi,
Please check the thread How to Insert image into
database unable to insert data into database unable to insert data into
database hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into
database based
unable to insert data into database unable to insert data into
database hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into
database based
unable to insert data into database unable to insert data into
database hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into
database based
unable to insert data into database unable to insert data into
database hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into
database based
connect to the database from JSPconnect to the
database from JSP How do you
connect to the
database from JSP?
A Connection to a
database can be established from a jsp page by writing the code to establish a connection using a jsp scriptlets
Connect database in Access to Netbean?Connect database in Access to Netbean? how to
connect database in micrsoft access to Netbean?i know it can be connected by using JDBC-ODBC bridge, can i know the steps in connecting the
database?
Is there any source code
cannot connect to database - JDBCcannot
connect to database Iam using eclipse in my system ,when connecting the
database mysql version 5.0 to the eclipse iam getting an error as ""Creating connection to mysql has encountered a problem.Could not
connect to mysql
connect with Database - SQLconnect with Database Hi,
when ever i m trying to
connect with 10g... problem with
java 2 v1.4 with oracle 10g.
But it worked well with the same code with
java 5.0 with 10g.
I am not sure whether it is technically correct answer
how to connect program to databasehow to
connect program to database Sir i want ur help in my program. I want to save the data in the
database. When i'll click on save button the entered data must be save in the
database.
I want an action performed method
unable to get datas from oracle databaseunable to get datas from oracle database Dear Sir,
I am again struck in my project..
i want to display data from oracle
database but i get...
org.apache.jasper.JasperException:
Unable to compile class for JSP:
An error occurred
Unable the get SubFolder Direcotry in Java?:- Unable the get SubFolder Direcotry in
Java?:-
Unable the get SubFolder Direcotry in
Java?:-
try {
String st1 = "C:\TestFolder; // Main Folder URL
File folder = new File(st1);
File[] listOfFiles = folder.listFiles();
for (File
Using Network Address To Connect to a Database to
connect a MySql
database with your application over a
network then you must load...
.style1 {
text-align: center;
}
How To Use Network Address To
Connect To The
Database
If a
database being connecte over a network then you need to get
How can I connect my database to my application ?How can I
connect my
database to my application ? How can I
connect my
database to my application?
Hi,
You can use JDBC API to
connect to
database from your
Java application.ADS_TO_REPLACE_1
Here is the sample
how to connect to MS access database in JSP?how to
connect to MS access
database in JSP? how to
connect to MS access
database in JSP? Any seetings/drivers need to be set or installed before it? Please tell what needs to be done after creating a table with an example
Java Connect to and FTP ServerJava Connect to and FTP Server What is the code for
Java Connect to and FTP Server? How to establish a connection to FTP server in
Java?
Thansk... the apache commons library to
connect/login to FTP server.
Link of complete example
How to connect to MySql Database from Servlet?;
font-weight: bold;
}
How to
connect to MySql
Database from Servlet... will show you how to
connect to
MySQL
database and perform select operation. You will learn the JDBC steps
necessary to
connect to the MySQL
Database and execute
Unable looping using JOptionPane - Java BeginnersUnable looping using JOptionPane import javax.swing.*;
public class Shop{
public static void main(String [] args){
Shop shop = new Shop();
String mainMenu= "(MAIN SCREEN )";
mainMenu+= "\n1) Computer Menu