Java and Access database
Hello,
I have an application with an access database. The access database (the access file) is in the same directory as all java files in c:\programs\eclipse\workspace\javaBooks.
The connection method looks as follows:
public boolean getConnection(String url,String user, String passw)
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection(url,user,passw);
DatabaseMetaData dbmd = con.getMetaData();
System.out.println("Connected to " + dbmd.getURL());
System.out.println("Version " + dbmd.getDriverVersion());
System.out.println("DBMS: " + dbmd.getDatabaseProductName());
return true;
//System.out.println("AutoCommit: " + con.getAutoCommit());
//rs=dbmd.getTables(null,"%","%",null); // Driver is not capable!
catch (java.sql.SQLException e)
System.err.println("Can't connect to database");
System.err.println(e.getMessage());
return false;
catch (ClassNotFoundException e)
System.err.println("Can't connect to database");
System.err.println(e.getMessage());
return false;
At the beginning when I start the application a form is displayed where I have to indicate an url and a password.
Does anybody know how I have to configure the corresponding things to use the database with the application?
You access (ahem) Access through the JdbcOdbcDriver,
which comes with Java.Not bad, not bad.
World spins
RD-R
� {�
Similar Messages
-
Hi I have a problem that I have been working on for a couple days now. It is on inserting, deleting and updating a database table. I wrote a small simple java program to insert a record into the table called Table1. I have my ODBC set up with the name tester1. I have another program that queries the same database table and it works fine. but I can't get this program to work. The code that I am using is from a textbook, the program compiles fine but when I run it it gives me an error -> SQL Error: java.sql.SQLException: General error 0 S1000
I have 7 columns in the database table. The first two are numbers and the rest are text. The first colmns is the primary key.
Can anyone see what is the problem?
Here is the code:
import java.sql.*;
public class databasetest1b {
public static void main(String[] arguments) {
String data = "jdbc:odbc:tester1";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection(
data, "", "");
PreparedStatement st = conn.prepareStatement(
"INSERT INTO Table1 VALUES(?,?,?,?,?,?,?)");
st.setString(1,"1");
st.setString(2,"12345");
st.setString(3,"ethan");
st.setString(4,"pats");
st.setString(5,"kid");
st.setString(6,"single");
st.setString(7,"rich");
st.executeUpdate();
conn.close();
} catch (SQLException s) {
System.out.println("SQL Error: " + s.toString() + " "
+ s.getErrorCode() + " " + s.getSQLState());
} catch (Exception e) {
System.out.println(" Error: " + e.toString()
+ e.getMessage());
All I would like to be able to do is add a record into the table. Then I can figure out how to change fields and update them.Greetings,
Have you tried sending the first two using
setInt(1, 1);
setInt(2, 12345)
since they are numbers?
Don't know how picky your database is but it might not like the paranthesis format or might actually require a SQL int datatype.
Hope that helps,
-J -
Dates, java, and Access Databases
I have my Access DB set up with three date fields, all of them are date/time and short dates. In my interface (done with NetBeans) I have the three text fields. I need to be able to have formatted entry, and then when I want to save to the Access DB I need to save the appropriate information. Up to this point, the only problem I have is with the formatted entry.
However, when I try to save with a field that has no date entered, I get a data type mismatch error. I don't want to store zeroes in the fields, I just want to store the dates properly, and if no date, then have the field in the DB blank.
Any suggestions or help?However, when I try to save with a field that has no
date entered, I get a data type mismatch error. I
don't want to store zeroes in the fields, I just want
to store the dates properly, and if no date, then
have the field in the DB blank. No. You want to have the field in the DB contain null. So you need to call setNull on your PreparedStatement if the input field is empty and setDate if it contains a valid date. -
Linking Java to Access Database tables
Hello,
I need use JCreator to link Java to Access Database tables.
Could any one tell me what kind of drivers I need use?
Also, where could I find the examples of linking Java to Access Database tables?
Thank you,
DanielThanks.
I have read the tutorial and downloaded the sample code from the web http://java.sun.com/docs/books/tutorial/jdbc/
In the CreateCoffee.java programming, I made the following changes:
// String url = "jdbc:mySubprotocol:myDataSource";
String url = "jdbc:odbc:DB1";
DB1 is an Access Database file located in the same folder as CreateCoffee.java.
//Class.forName("myDriver.ClassName");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Every time when I run the CreateCoffee.java programming, it shows the following running error:
SQLException:[Microsoft][ODBC Driver Manager]
Data source name not found and no default driver specified.
Could any one have any suggestions for solving the above problem?
Thank you,
Daniel -
Hello Good morning. Maybe this message has not a lot to do at all with Java. Iam doing a program in Java using UML(both OO).Wouldn't be a contradiction to use MS Access as "DataBase" since Java and UML are Object Oriented?.
Thanks.
CELH.You are quite right. Thus, I wonder about it because it's strange mixing Object Oriented programming and modeling with a relational DataBase. Maybe a Object Oriented DataBase will suit it better, but then again, you are right: There a few known Object Oriented DataBase.
Thanks.
CELH -
Hello,
Does anyone know how to store ImageIcon from the interface into Access Database and retrieve ImageIcon from Access Database to the interface?
Thanks,
DanielWell, this page has some examples for storing and retrieving images as BLOBs from databases:
http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/exercises.html
As for getting the image, you wouldn't generally store the raw image, but would save it as a JPEG or other format. If you search this forum for "save JPEG", I'm sure you'll find many posts on the topic. -
Uk date format issue with ASP and Access Database
I have an Asp form which updates records in an Access
database. Problem is
that the date format in the database record is dd/mm/yyyy
(UK), when
the record is displayed on the form it is mm/dd/yyyy(US)
which after I
update the record in the database the date has changed to the
new format.
I have tried everything I can to change the format but to no
avail...anyone any ideas how I can resolve this issue?
Thanks
Stevestevo.s wrote:
> Hi
>
> I have tried changing the format on the date field on
the server behaviours
> panelto ddmmyyy. Also have tried to set the form field
format to ddmmyy. I have
> also tried to use a function I got from a posting
somehwere on the net to no
> avail. <%function ddmmyyyy(varDate)
> ddmmyyyy = Day(DateValue(varDate)) & "/" &
Month(DateValue(varDate))
> & "/" & Year(DateValue(varDate))
> end function
>
> I believe that this is a recognised issue with
Dreamweaver and Access but
> can't seem to grasp the work around! Problem being I am
teaching myself through
> books and internet articles and can be weeks at a time
without being able to
> look at the issue..each time I come back to it it is
like starting all over
> again! I was hoping that somewhere out there there is a
simple solution the
> issue perhaps a date picker with the built in
functionality to address the
> issue...I am keen to understand how to deal with the
issue rather than just
> change my database date field to fudge the problem as I
am in the UK and when I
> eventually start to use the application I would like
there to be some
> consistency with dates and that users are familiar with
the format.
>
> Any help gratefully received!
Its not Dreamweaver, or Access, its your servers locale, its
set to US
format, not the UK.
On your page at the top use:
<% Session.LCID = 2057 %>
This will force the page into using UK formatted dates. Use
it on any
page that needs to format the page correctly.
Dooza
Posting Guidelines
http://www.adobe.com/support/forums/guidelines.html
How To Ask Smart Questions
http://www.catb.org/esr/faqs/smart-questions.html -
Crystal Reports and Access database connection error
I had this in a different forum with no hits, so I am trying this one.
A person that I work with has multiple reports set up that pulls from an Access database that is password protected. When we moved everything over to a new computer, those reports now say that it cannot access the fields inside the database. It never pops up with a login screen either, like it does on the old computer. I played around with the ODBC, with no luck, couldn't get anything to work. I have also tryed relinking the database, but I keep getting connection problems. We are on a network, so her settings should have all moved with the new computer. Along with the database and the reports being on the server, so they were never moved. I am thinking it has something to do with a system file.
I also found this document on this site, but cannot find the download it mentions, sounds similar to my problem.
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/208b8fe5-681e-2b10-d2bb-b201f266d0ab
Does anybody know how to fix this without the utility mentioned in the above link, or know where I can get the utility??
We are using Access 2007 and Crystal Reports 7. The database is not save as an Access 2007 database, but a regular mdb.
Please Help!Post Author: ejthunder
CA Forum: Crystal Reports
Hello Chris,
Crystal Reports does not store the database password with the RPT file. This is by design (Crystal is not a database security product). This is true of all versions of Crystal Reports.
If your users need to see fresh data when opening the reports then they will have to log in by providing at least the password.
You can send reports with Saved Data that won't try to hit the database, but the data won't refresh either. To save data with the report go to the File menu and click next to Save Data with Report. Refresh the report and then save it. The report will now have saved data and won't try to hit the database when opened. If the user hits the refresh button then they will get prompted to log into the database.
I hope this helps.
EJ -
I want to know if flex is able to access an access database
either via coldfusion or flash remoting?1) I don't know much about flash remoting, but sure flex
application would be able to access any coldfusion app. and it
won't matter what db CF app is fronting.
2) if i understand your question correctly, you're talking
about the webserver? if that's the case all you need to have on the
server is the SWF file.
ATTA -
Vista Dreamweaver and Access database
I am trying to connect an Access database to an aspx-page in
Dreamweaver and
all I get is 'The program has stopped working'
How can I avoid this?
reidarTI am trying to connect an Access database to an aspx-page in
Dreamweaver and
all I get is 'The program has stopped working'
How can I avoid this?
reidarT -
CS5 Dreamweaver and Access database
I have set up a connection from DW to an Access database and I have found a problem returning a record to a new ASP page from an ASP page with a Log In User server behaviour. I get the following error message:
ADODB.Field
error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/Access Database Work/2 Homepage.asp, line 34
The expected result is that the user logs on correctly and the second page is displayed with their details. My recordset on the second page has a filter that needs to equal one of the inputs from a form element on the inital page. This all works perfectly when not using the Log In User server behaviour and I just create my own form.
I have tried adapting code and setting values to variables to pull through (I have a basic understanding of code), but I am a real beginner with ASP and not sure of syntax etc. and just keeping creating more errors.
Any sugggestions would be really appreciated.Thank you for your response Murray *ACP*
Below is the code for the initial page, which containls the Log In User server behaviour:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/connAccessDatabase.asp" -->
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername = CStr(Request.Form("txtID"))
If MM_valUsername <> "" Then
Dim MM_fldUserAuthorization
Dim MM_redirectLoginSuccess
Dim MM_redirectLoginFailed
Dim MM_loginSQL
Dim MM_rsUser
Dim MM_rsUser_cmd
MM_fldUserAuthorization = ""
MM_redirectLoginSuccess = "2 Homepage.asp"
MM_redirectLoginFailed = "incorrect.html"
MM_loginSQL = "SELECT userID, password"
If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
MM_loginSQL = MM_loginSQL & " FROM [customers logon] WHERE userID = ? AND password = ?"
Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")
MM_rsUser_cmd.ActiveConnection = MM_connAccessDatabase_STRING
MM_rsUser_cmd.CommandText = MM_loginSQL
MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param1", 200, 1, 255, MM_valUsername) ' adVarChar
MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param2", 200, 1, 255, Request.Form("txtPWord")) ' adVarChar
MM_rsUser_cmd.Prepared = true
Set MM_rsUser = MM_rsUser_cmd.Execute
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session("MM_Username") = MM_valUsername
If (MM_fldUserAuthorization <> "") Then
Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
Else
Session("MM_UserAuthorization") = ""
End If
if CStr(Request.QueryString("accessdenied")) <> "" And false Then
MM_redirectLoginSuccess = Request.QueryString("accessdenied")
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<p>Enter your details</p>
<form id="form1" name="form1" method="POST" action="<%=MM_LoginAction%>">
<table width="30%" height="59" border="0" cellpadding="5" cellspacing="0">
<tr>
<td width="103">User ID</td>
<td width="368"><input type="text" name="txtID" id="txtID" /></td>
</tr>
<tr>
<td>Password</td>
<td width="368"><input type="text" name="txtPWord" id="txtPWord" /></td>
</tr>
<tr>
<td> </td>
<td width="368"><input type="submit" name="button" id="button" value="Submit" /></td>
</tr>
</table>
</form>
<p> </p>
</body>
</html>
Below is the code for the second page which show the appropriate record depending on the user ID
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/connAccessDatabase.asp" -->
<%
Dim rstest__MMColParam
rstest__MMColParam = "1"
If (Request.Form("txtID") <> "") Then
rstest__MMColParam = Request.Form("txtID")
End If
%>
<%
Dim rstest
Dim rstest_cmd
Dim rstest_numRows
Set rstest_cmd = Server.CreateObject ("ADODB.Command")
rstest_cmd.ActiveConnection = MM_connAccessDatabase_STRING
rstest_cmd.CommandText = "SELECT * FROM [customers logon] WHERE userID = ?"
rstest_cmd.Prepared = true
rstest_cmd.Parameters.Append rstest_cmd.CreateParameter("param1", 200, 1, 255, rstest__MMColParam) ' adVarChar
Set rstest = rstest_cmd.Execute
rstest_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
welcome
<%=(rstest.Fields.Item("userID").Value)%>
</body>
</html>
<%
rstest.Close()
Set rstest = Nothing
%> -
Dreamweaver CS5 and Access Database
I have set up a connection from DW to an Access database and I have found a problem returning a record to a new ASP page from an ASP page with a Log In User server behaviour. I get the following error message:
ADODB.Field
error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/Access Database Work/2 Homepage.asp, line 34
The expected result is that the user logs on correctly and the second page is displayed with their details. My recordset on the second page has a filter that needs to equal one of the inputs from a form element on the inital page. This all works perfectly when not using the Log In User server behaviour and I just create my own form.
I have tried adapting code and setting values to variables to pull through (I have a basic understanding of code), but I am a real beginner with ASP and not sure of syntax etc. and just keeping creating more errors.
Any sugggestions would be really appreciated.Here is the code for the Log In User server behaviour page:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/connAccessDatabase.asp" -->
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername = CStr(Request.Form("txtID"))
If MM_valUsername <> "" Then
Dim MM_fldUserAuthorization
Dim MM_redirectLoginSuccess
Dim MM_redirectLoginFailed
Dim MM_loginSQL
Dim MM_rsUser
Dim MM_rsUser_cmd
MM_fldUserAuthorization = ""
MM_redirectLoginSuccess = "2 Homepage.asp"
MM_redirectLoginFailed = "incorrect.html"
MM_loginSQL = "SELECT userID, password"
If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
MM_loginSQL = MM_loginSQL & " FROM [customers logon] WHERE userID = ? AND password = ?"
Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")
MM_rsUser_cmd.ActiveConnection = MM_connAccessDatabase_STRING
MM_rsUser_cmd.CommandText = MM_loginSQL
MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param1", 200, 1, 255, MM_valUsername) ' adVarChar
MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param2", 200, 1, 255, Request.Form("txtPWord")) ' adVarChar
MM_rsUser_cmd.Prepared = true
Set MM_rsUser = MM_rsUser_cmd.Execute
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session("MM_Username") = MM_valUsername
If (MM_fldUserAuthorization <> "") Then
Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
Else
Session("MM_UserAuthorization") = ""
End If
if CStr(Request.QueryString("accessdenied")) <> "" And false Then
MM_redirectLoginSuccess = Request.QueryString("accessdenied")
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<p>Enter your details</p>
<form id="form1" name="form1" method="POST" action="<%=MM_LoginAction%>">
<table width="30%" height="59" border="0" cellpadding="5" cellspacing="0">
<tr>
<td width="103">User ID</td>
<td width="368"><input type="text" name="txtID" id="txtID" /></td>
</tr>
<tr>
<td>Password</td>
<td width="368"><input type="text" name="txtPWord" id="txtPWord" /></td>
</tr>
<tr>
<td> </td>
<td width="368"><input type="submit" name="button" id="button" value="Submit" /></td>
</tr>
</table>
</form>
<p> </p>
</body>
</html>
Below is the code for the code that should return the record that matches the user ID:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/connAccessDatabase.asp" -->
<%
Dim rstest__MMColParam
rstest__MMColParam = "1"
If (Request.Form("txtID") <> "") Then
rstest__MMColParam = Request.Form("txtID")
End If
%>
<%
Dim rstest
Dim rstest_cmd
Dim rstest_numRows
Set rstest_cmd = Server.CreateObject ("ADODB.Command")
rstest_cmd.ActiveConnection = MM_connAccessDatabase_STRING
rstest_cmd.CommandText = "SELECT * FROM [customers logon] WHERE userID = ?"
rstest_cmd.Prepared = true
rstest_cmd.Parameters.Append rstest_cmd.CreateParameter("param1", 200, 1, 255, rstest__MMColParam) ' adVarChar
Set rstest = rstest_cmd.Execute
rstest_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
welcome
<%=(rstest.Fields.Item("userID").Value)%>
</body>
</html>
<%
rstest.Close()
Set rstest = Nothing
%> -
How can I use an Access Database with a web applet? I can do it on my machine because I can set the data source. However, I can't set the data source on the server I'm uploading my web page to. Suggestions?
You may be able to find some third party vendor that wrote a JDBC driver for Access that allows you to connect directly, but I doubt you'll find one.
I don't know what you are needing to do exactly, but have you considered using an XML file? -
Hi! I have one table "Student" and one "Course". They are connected via a many-to-many relationship.
The database is Access.
In the connecting table I register the grades the student get on a course. This works fine in some cases but not in others.
I get an error message saying something like "Can't add or change the row, it takes an related row in the course table". But I have checked and the row is there.
A funny thing is, that when I added a course in the course table, it was other combinations of student and course that didn't work.
I'll be happy to post my files to anyone who wants to take a look.
This is the error message: (and I also get a .ldb file for locked rows)
java.sql.SQLException: [Microsoft][Drivrutin f�r ODBC Microsoft Access] Du kan inte l�gga till eller �ndra posten. Det kr�vs en relaterad post i tabellen 'Kurs'.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3111)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:288)
at Databashanterare.betygReg(Databashanterare.java:657)
at BetygReg.actionPerformed(BetygReg.java:389)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
at java.awt.Component.processMouseEvent(Component.java:5100)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)Well, I do have auto increment in "course" and "student" but not in the third table. It can't be? since it depends on what student and what course you choose.
public String sqlInsert(String tabell, String kursNamn, String Litteratur)
String status = null;
try
int idnr = 0;
int i = 0;
//int [] temp = new int[100];
if(kursNamn.equals("") || Litteratur.equals(""))
status = "Du m�ste ange b�de kurs och litteratur!";
if(status == null)
skapaKoppling();
rs = stmt.executeQuery("select * from " + tabell + " order by Kid");
while(rs.next())
idnr++; //R�knar ut sista postens idnr.
temp[idnr] = rs.getInt("Kid"); // H�r l�ggs alla kvarvarande idnr
idnr = temp[idnr]; //Sista postens idnr l�ggs i variabel.
System.out.println("idnr: " + idnr);
while(i < 20)
System.out.println("post "+i+" �r "+temp);
i++;
idnr++;
//int antal = stmt.executeUpdate("insert into Exempel values(1,'Blaha','Mer blaha','2002-02-18 19:23:21',"+true+")");
int antal = stmt.executeUpdate("insert into "+tabell+" values("+idnr+",'"+kursNamn+"','"+Litteratur+"')");
System.out.println("Antal rader som ber�rdes: " + antal);
status = "Kurs registrerad!";
avslutaKoppling();
}//End if
catch(SQLException sqle)
sqle.printStackTrace();
return status;
}//End metod SQLinsert
public String sqlInsert2(String tabell, String studentNamn)
String status = null;
try
int idnr = 0;
int i = 0;
int [] temp = new int[100];
if(studentNamn.equals(""))
status = "Du m�ste ange student!";
if(status == null)
skapaKoppling();
rs = stmt.executeQuery("select * from " + tabell + " order by Sid");
while(rs.next())
idnr++; //R�knar ut sista postens idnr.
temp[idnr] = rs.getInt("Sid"); // H�r l�ggs alla kvarvarande idnr
idnr = temp[idnr]; //Sista postens idnr l�ggs i variabel.
System.out.println("idnr: " + idnr);
//Test
while(i < 20)
i++;
System.out.println("post "+i+" �r "+temp[i]);
idnr++; //S�tter idnr till nummer efter sista post.
//int antal = stmt.executeUpdate("insert into Exempel values(1,'Blaha','Mer blaha','2002-02-18 19:23:21',"+true+")");
int antal = stmt.executeUpdate("insert into "+tabell+" values("+idnr+",'"+studentNamn+"')");
System.out.println("Antal rader som ber�rdes: " + antal);
status = "Student registrerad!";
avslutaKoppling();
}//End if
catch(SQLException sqle)
sqle.printStackTrace();
return status;
}//End metod SQLinsert 2 -
Problem with applications and accessing database
Hi
I have a serious problem with my applications.I was trying to change "users"'s folder icon so I changed the setting in information.I don'y know what I did but It made these problems:
many of applications does not open for example
itunes-->The folder "iTunes" is on a locked disk or you do not have permission...
picasa alerts me with a database error
yahoo messenger just pops up once and doesn't open.
firefox the same problem
net monitor alerts with a database problem.
evernote same problem
all of my address book is erased.
I think somehow I removed the db files or I changed the permission and the programs can not access to their db files.don't know the last thing I have done was trying to change the icon and after that I found out about the problem.Maybe sth else caused the problem . anyway I copied all of my files to a new user and I removed the user with problems & everything is ok here.thank u all.
Maybe you are looking for
-
So when I try to update or download an app it says I don't have enough storage. I don't know how to use iCloud and stuff soo what do I do? Help! I don't wanna delete any pics either.
-
What's the deal when syncing to an iPhone? Unexpected results
I'm new to Aperture, and have had odd issues when syncing selected Aperture albums through iTunes to my iPhone 3G. First, the photos appear in chronological order in Aperture 2, but are completely random when browsing the albums on my iPhone. Also, e
-
Hi, I need to know where are the caluculated values for freight FRC1 is getting stored in the purchase order conditions.
-
Paid Subscription (Photoshop for Photographers)- Application Manager Says Otherwise
After wanting to smack my MacBook multiple times, I keep getting a very grumpy message from my application manager insisting that my subscription is expired. Now, had I not JUST paid my bill a week or so ago, I would understand this. Also keep in min
-
The old ALDUS PageMaker (circa 1992) used to have a file that printed out all the characters in a font - you merely changed the font to see all the characters; i.e., times roman showed all the characters in that font, changing to symbol showed all th