How to connect java to MS Access
How to connect java to MS Access using jdbc
Can U write the complete code for it ? How to interact with the fields ?
G O O G L E
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2691&lngWId=2
http://blog.taragana.com/index.php/archive/how-to-access-ms-access-database-from-jdbc/
Similar Messages
-
An error occured when connecting java with Ms Access
Hello Everybody
I am a new developer in java and want to connect java with Microsoft Access
i am using JCreator LE
My code is to insert 3 records for 3 members and then save them in DB and retrieve the information
Here is the code
import java.sql.*;
public class Project3 {
public static void main(String[] args) {
try {
System.out.println("Beginning Connection");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String accessFileName = "Information";
String connURL = "jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ="+accessFileName+".mdb;PWD=";
Connection con = DriverManager.getConnection( connURL ,"","");
Statement stmt = con.createStatement();
System.out.println("Connection done successfully");
stmt.execute("Create table Member(Name String,ID Integer)");
stmt.execute("insert into Member values ('Joe','1234')");
stmt.execute(" select * from Member");
ResultSet rs=stmt.getResultSet();
if (rs != null)
while (rs.next()){
System.out.println("Name: "+rs.getString("Name")+ "ID: " + rs.getString("ID"));
stmt.close();
con.close();
catch (Exception e) {
System.out.println("An error Occurred in Connecting with the DB " );
}and the error is
Beginning Connection
Connection done successfully
An error Occurred in Connecting with the DB
it didn't insert information in the DBWell, thank u i have traced the error and fx it
but
how to modify the code and keep the user entering 3 values and search for the entered values??
Here is the correct code
import java.sql.*;
public class Project3 {
public static void main(String[] args) {
try {
System.out.println("Beginning Connection");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String accessFileName = "jdbc:odbc:Project";
String connURL = "jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ="+accessFileName+".mdb;PWD=";
Connection con = DriverManager.getConnection( accessFileName);
Statement stmt = con.createStatement();
System.out.println("Connection done successfully");
stmt.execute("Create table Member(Name String,ID Integer)");
stmt.execute("insert into Member values ('Joe','1234')");
stmt.execute(" select * from Member");
ResultSet rs=stmt.getResultSet();
if (rs != null)
while (rs.next()){
System.out.println("Name: "+rs.getString("Name")+ "ID: " + rs.getString("ID"));
stmt.close();
con.close();
catch (Exception err) {err.printStackTrace();}
} -
How to connect Java and Microsoft SQL Server 2000
hi,
could anyone please teach me how to connect Java and SQL Sever 2000?? if possible could you guys provide me with an example??? i could hardly find any relevant resources about it...
Thanks ~!thanks for the information...
by the way hv any working module on it?? i'm new to
both Java and Microsoft SQL Server... Thanks againFirst things first... you should read this:
http://java.sun.com/docs/books/tutorial/jdbc/
This is microsofts official JDBC Driver: http://www.microsoft.com/sql/downloads/jdbcregister.asp
Install it and the documentation has some usage examples -
How to connect Java into BarTender Label Printing Software
Hi,
I have one problem, my company have bartender label printing software 32 bit version, previously they use VB6 for controlling the dublicate printing of lable,but the software is gone. Now i want to do this in Java, but i don't know how to connect java into Bartender software.
my company using old version, it accept only VB6. My Boss said can buy new Bartender Software but i don't know how to link and control dublicate printing. if anybody knows this connection between Bartender and Java please help me.
if bartender New version support this features please send the link and example source code please help me.
AnbuAathiHi , i have the similar task ,where i need to connect my web portal application with the bartender software .I did a hugh R&D to integrate Java application with Bartender software but did not find any luck .So i request to provide the needed help to integrate my Java Application with Bartender software .
Thanks in Advance
Mohan -
How to connect Java to oracle Database Express Edition?
Anyone can help me?
How to connect JAVA TO ORACLE DATABASE EXPRESS EDITION?I suggest you to read this article:
http://wiki.oracle.com/page/JDBC
Regards,
Ricky -
How to connect Java to crystal report
How to connect java with crystal report ?
Which are the API's for thatIn all this time you never considered searching?
Cross post
http://forum.java.sun.com/thread.jspa?threadID=791154 -
How to connect java in mysql....
how to connect java in mysql.... help me guys
am newbie...http://www.mysql.com/products/connector/j/
download the JDBC driver and read the docs.
if you don't know JDBC, Google for "Sun JDBC tutorial" and study it.
don't ask for sample code. there's plenty out there.
% -
How to connect java with oracle
can any body show me the code of how to connect java with oracle database.
thank youTo configure Oracle JDBC:
1. Add Oracle JDBC JAR file classes12.zip or ojdbc14.zip to classpath.
2. Load and register the JDBC driver.
Class.forName("oracle.jdbc.driver.OracleDriver");
3. Obtain a connection:
String url="jdbc:oracle:thin:@<host>:1521:<database>
Connection con = DriverManager.getConnection(url,
"myLogin", "myPassword");
4. Create a SQL statement.
Statement stmt = con.createStatement();
5. Obtain a result set.
ResultSet rs = stmt.executeQuery(
"SELECT ..."); -
Plz help....
How to Connect a Java With C ....using the JNI, Java Native Interface. there are tons of tutorials on the web about it, that will explain far better and more completely than a few posts on a forum
-
How to connect Java Application with database!
Dear all, now I am create a dababase application. My database use JData Store. But I don't know how to connect application with it. Can you tell me this proplem?
Thank!Do a google search for JDBC, or go buy a book.
You will need a JDBC driver which supports your database. Or you might be able to use the JDBC-ODBC bridge if there's an ODBC driver for your database. -
How to connect JAVA API into NACT- NTS 2000?(TELECOM)
hai to all,
i need help.if there is any one working in telecom Project . (will be more helpfull). i want to connect JAVA API into NACT-NTS2000 (it's (NTS2000) fully based on JAVA ).if anybody know the solution mail me ID [email protected]
thanks
dhanaHi,
Could you give us some URL pointers to the NACT-NTS2000 technology so we have some sense of what we are talking about technically?
Thanks, -
How to connect java with database without any dsn.
is there any way to connect java with database with out creating any dsn..like we do in ado in vb by providing provider.
Sure use a type 4 driver. No DSN.
-
How to connect JSp to ms-access?
hello Everybody,
I have a database created in MS-Access. Database name "est". Table name "Customer".
I have created System DSN by name "est" for Access database.
This Customer table contains user-id and password.
Now, from front end, using JSP, i have created a login page. USer will enter their id and password....
in the following code, i am trying to access this table IF there is any record with user entered cid and password, count's value will be 1 else 0.
<%@ page language="java"%>
<%@ page import="java.text.*,java.sql.*,java.util.*,javax.servlet.*,javax.servlet.http.*" %>
<%
//creating a Connection, to connect to the database
try {
String uid = request.getParameter("Lng").trim();
String pwd=request.getParameter("pwrd").trim();
String query = new String();
ResultSet rs = null;
Connection con = null;
//initializing the JDBC-ODBC bridge driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//open a connection to the database
con = DriverManager.getConnection("jdbc:odbc:acc",uid,pwd);
//execute the query
Statement stmt = con.createStatement();
query="select count(*) as count1 from est.Customers where cid='"+uid+"'password='"+pwd+"'";
System.out.println(query);
rs=stmt.executeQuery(query);
System.out.println("creating the connection is success");
session.setAttribute("uid",uid);
session.setAttribute("pwd",pwd);
session.setAttribute("connect","yes");
response.sendRedirect("");
} catch(Exception e)
System.out.println("Error in creating the connection"+e);
out.println("Error in creating the connection");
response.sendRedirect("login1.jsp");
%>
<html>
<head><title>Validation Screen</title>
</head>
<body>
<FONT STYLE=Courier: color=RED SIZE=5>
<p align=center><b><font SIZE=4 color=brown face=" ">LOGGEDINN SUCCESSFULLY</font></b>
</body>
</html>
But, i am getting "No data found error". Can anyone please help me in this regards, please?
Regards,
Thanks in advance for your time and help
Ashvinii have to connect jsp to sql server
how can i do this::::::::::::
actually,i have written the code in textpad in java file which is working fine
but when i apply the same code in jsp file in weblogic , it is giving error in line
"DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());"
weblogic is not recognising "com.microsoft" package in this line
but i haven't done anything special in textpad
looking forward for reply
My code written in textpad:::::::::::
import java.sql.*;
* Microsoft SQL Server JDBC test program
public class TestCalculator {
public TestCalculator() throws Exception {
/******************* Get connection ************************************/
DriverManager.registerDriver(new
com.microsoft.jdbc.sqlserver.SQLServerDriver());
Connection connection = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://192.9.203.153:1433","attend","attend");
if (connection != null) {
System.out.println();
System.out.println("Successfully connected");
System.out.println();
System.out.println("HELLO");
Statement stmt;
try
stmt = connection.createStatement();
ResultSet resultSet = stmt.executeQuery("Select * from tblcode where empcode='2923'");
while (resultSet.next()){
System.out.println(resultSet.getString(1) + " " + resultSet.getString(2)+" "+resultSet.getString(3));
resultSet.close();
//stmt = conn.createStatement();
//stmt.executeUpdate("insert into EmployeeData " +
//"values('name', 'salary','joiningDate','empId','leavingDate')");
/*stmt.executeUpdate("insert into cust_profile " +
"values('name2', 'add2','city2','state2','country2')");
stmt.executeUpdate("insert into cust_profile " +
"values('name3', 'add3','city3','state3','country3')"); */
stmt.close();
connection.close();
catch (Exception e)
e.printStackTrace();
}//TestCalculator
public static void main (String args[]) throws Exception {
TestCalculator test = new TestCalculator();
}//End of class -
How to connect Java with Acces (DSN Less)
Hi, I'm try to connect an Access DataBase in Java with an example. I find it in this forum, but don't work...
I've my database in the folder Data, and its name is BaseDat.mdb...
I'm working in NetBeans 5.5, and the DataBase is in the Folder: "C:/Documents and Settings/MetalTux/POOL/src/Data/BaseDat.MDB"...
This way, its work, but It's another way to use this... without the "C:/Documents and Settings/MetalTux/POOL/src/"????
Please help me... and sorry my english...
Regards...I have this in my code:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conec = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/Documents and Settings/MetalTux/POOL/src/Data/BaseDat.MDB");
This is OK... work in my code...
But I want to know if there's another way to do this... without "C:/Documents and Settings/MetalTux/POOL/src" code....
In Visual Basic I do this with "App.Path", but I don't know how I can do the same thing in Java...
Please help me... -
How to connect java project to sql server 2008 r2 database
i want to create an java application which has to create a database and later access it. My problem is that i am not able to connect sql server 2008 r2 database driver on to the netbeans.i have sql server 2008 r2 installed on my system.please
suggest me the step by step procedure to establish the connectionHi ENG,
To establish a connection to SQL Server from a Java project, you have to download the JDBC driver for SQL Server from
here.
After extracting the jar files(like sqljdbc.jar) from the above link, add the driver to the netbeansIDE.
Test establishing a connection with the below Java Class.
import java.sql.*;
public class Test {
public static void main(String[] srg) {
String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; //load the jdbc driver
String dbURL = "jdbc:sqlserver://localhost:1433; DatabaseName=test"; //connection string to the db hosted on localhost
String userName = "sa"; //user name
String userPwd = "123456"; //password
Connection dbConn;
try {
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
System.out.println("Connection Successful!"); //print Connection Successful! if connection establishes
} catch (Exception e) {
e.printStackTrace();
A demonstration video from Youtube for you reference.
Connect NetBeans Project with Microsoft SQL Server 2008 - YouTube
Since this is a question regarding Java, I suggest you post your subsequent questions to a java dedicated forum. It is appropriate and more experts will assist you.
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support
Maybe you are looking for
-
How do you make pages default document reader
Hi I have just started using pages and i cant seem to work out how to make it the default application to open up the many documents i have. Every time i open a document it opens in textedit, i know that you can choose in properties with which program
-
How to export video that plays back smoothly?
I have an HD project in Premiere Pro CS4 that is about 9 minutes. When I render out to Flash for the web, once it's all buffered it plays back real smooth. So the client wants a copy of the "file" to be played on his computer running Windows and Wi
-
Changing Reporting Services Account via SMO
I am in the process of changing our Service Accounts to use virtual accounts in place of using local accounts. I am using SMO to change the SQL Server, SQL Server Agent and Analysis Services accounts to the virtual account and works great. Question
-
Cannot create JVM message box in WLS 92 admin console
Hi, I want to open a new windows process from weblogic admin console. I wanted to know if there is a way to launch a jvm from console. If I use Runtime.getRuntime().exec(cmd), cmd is a javaw command, in my console extension, I get "cannot create JVM"
-
Installing printer drivers on x86 and x64 OS clients from print server
Hi experts, I have a print server win 2008 r2 with some printers installed on it including x86 and x64 drivers. 1. I wanted to install printer drivers on x86 and x64 CLIENT OS (win 7/8 ) from the print server. 2. This installation should in in back