|
hi,
I have a database which has 2 tables, Employees and Foods
I want to show their data in a jTable, since i'm new to JAVA, I used binding. (Table Content -> Bound -> import Data From ...)
it works fine and perfect for Employees, but when i try to do the same to Foods it gives me a long long error, I'll just copy a few lines of error at the end. so if any one knows where is my problem please tell me
Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: No Persistence provider for EntityManager named MainRestaurantDBPU: Provider named oracle.toplink.essentials.PersistenceProvider threw unexpected exception at create EntityManagerFactory:
oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
Local Exception Stack:
Exception [TOPLINK-30005] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@16bd4dc2
Internal Exception: javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
Exception Description: predeploy for PersistenceUnit [MainRestaurantDBPU] failed.
Internal Exception: Exception [TOPLINK-30007] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while loading class: rest.Food_1 to check whether it implements @Entity, @Embeddable, or @MappedSuperclass.
Internal Exception: java.lang.ClassNotFoundException: rest.Food_1
|
|
|
|
|
I have a system include : apache tomcat webserver, a JSP/Servlet website, a local network (LAN).
I want to check user's connection to my webiste by using java code.
Please to help me !. Thanks so much.
|
|
|
|
|
Where "check user's connection" means what exactly?
In the basic sense it doesn't mean anything because your server can't run code on behalf of a user unless the user is connected. So by definition it is meaningless.
|
|
|
|
|
import java.sql.*;
import java.io.*;
import java.util.Date;
import java.util.*;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Aproject extends HttpServlet{
Connection con;
PrintWriter out;
ResultSet rs;
Statement st;
String s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14;
String service,service1,service_addp,service_delp,service_upp;
int cv;
public void init()
{
con=null;out=null;rs=null;
}
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
out=res.getWriter();
res.setContentType("text/html");
service=req.getParameter("ic_searchpname");
service1=req.getParameter("ic_searchpid");
service_addp=req.getParameter("ic_Addu");
service_delp=req.getParameter("ic_deleteu");
service_upp=req.getParameter("ic_Updateu");
try
{
if(service!=service1)
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:pro");
PreparedStatement pst;
String qry="select projectname,projectid,projectleader,client from project";
pst=con.prepareStatement(qry);
s1=req.getParameter("ic_newpname");
s7=req.getParameter("ic_pid"); //project name--string
s6="f";
rs=pst.executeQuery();
while(rs.next())
{
s2=rs.getString("projectname");
s3=rs.getString("projectid");
s4=rs.getString("projectleader");
s5=rs.getString("client");
if(s1.equals(s2))
{
s6="t";
res.sendRedirect("Aproject.html?ic_newpname="+s2+"&ic_pid="+s3+"&ic_pleadername="+s4+"&ic_clientname="+s5+"#top");
}else if(s7.equals(s3))
{
s6="t";
res.sendRedirect("Aproject.html?ic_newpname="+s2+"&ic_pid="+s3+"&ic_pleadername="+s4+"&ic_clientname="+s5+"#top");
}
}
if(!s6.equalsIgnoreCase("t"))
{
res.sendRedirect("Aproject.html?ic_msg=given_project_not_available");
}
pst.close();
}
else if(service_upp.equalsIgnoreCase("Modify Project"))
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:pro");
st=con.createStatement();
s8=req.getParameter("ic_newpname");
s9=req.getParameter("ic_pid");
s10=req.getParameter("ic_pleadername");
s11=req.getParameter("ic_clientname");
st.executeUpdate("update project set projectname='"+s8+"',projectid='"+s9+"',projectleader='"+s10+"',client='"+s11+"'where projectid='"+s3+"'");
res.sendRedirect("Aproject.html?ic_msg=given_details_updated");
st.close();
}
//hi....here my Delteing format is not working...i tried many methods to delete date from ms access database...but while running prg it prouce "java.lang.NullPointerException" error onl...pls say right coding to delete.............................
else if(service_delp.equalsIgnoreCase("Remove Project")){
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:pro");
///st=con.createStatement();
PreparedStatement pst;
String sql="DELETE *FROM project Where projectid=?";
pst=con.prepareStatement(sql);
//s12=req.getParameter("ic_newpname");
s13=req.getParameter("ic_pid");
//pst.setString(1, s12);
pst.setString(1, s13);
pst.executeUpdate();
//st.executeUpdate("DELETE FROM project WHERE projectid="+s13);
res.sendRedirect("Aproject.html?ic_msg=selected_project_deleted");
}
//HEre also while adding new data it producess "java.lang.NullPointerException " error....i nned help...sortly...
else if(service_addp.equalsIgnoreCase("Add New Project"))
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:pro");
PreparedStatement pst;
pst=con.prepareStatement("INSERT INTO project"+"(projectname,projectid,projectleader,client)"+"VALUES(?,?,?,?)");
s2=rs.getString("projectname");
s3=rs.getString("projectid");
s4=rs.getString("projectleader");
s5=rs.getString("client");
pst.setString(2, s2);
pst.setString(3, s3);
pst.setString(4, s4);
pst.setString(5, s5);
pst.executeUpdate();
res.sendRedirect("Aproject.html?ic_msg=selected_project_deleted");
pst.close();
}
else
{
res.sendRedirect("Aproject.html");
}
} catch(Exception e)
{
out.println(e.toString());
}
}
public void destroy()
{
try
{
con.close();
out.close();
rs.close();
}
catch(Exception e)
{
System.out.println("Unable to close connection:"+e);
}
}
}
|
|
|
|
|
Use code tags when you post code.
The exception stack trace tells you EXACTLY what line the error occurs on. That information is useful and there for a reason.
Following code is obviously wrong. The index doesn't start on 2. No idea if this is your problem or not.
pst=con.prepareStatement("INSERT INTO project"+"(projectname,projectid,projectleader,client)"+"VALUES(?,?,?,?)");
...
pst.setString(2, s2);
pst.setString(3, s3);
pst.setString(4, s4);
pst.setString(5, s5);
|
|
|
|
|
Hi, I'd like to make a program that talking(reply) to user
example
User: How do you do!
Computer : How do you do!
User: I'm tired
Computer : Have a rest !
& soon ,,,,,, thanks
|
|
|
|
|
Do not crosspost! You posted the same question in the C#-forum.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
btw, this is one exercice from one book and I'm starting on Java classes next week. so it IS from the school book but I don't got the patience to wait, already on chapter 7 =)
I got this array
int[] waste = {6,4,0,4,3,8,4,4,6,8};
the task is to make one function find the lowest value an how many if them to the output.
now I've been thinking on something like this
public int getLowWaste() {
int maksDager = 0;
int sum = 0;
for(int i=0; i<waste.length; i++) {
if(waste[i]<waste) {
maksDager = waste[i];
sum++;
}
}
return maksDager;
}
now I think this should work to get the lowest value of the array, but not how many of them.. I'm thinking that it will see 6, mark it as the lowest, go to next value and if it's lower, mark it as lowest and so on. but when the values are changed, how so I reset the counter ?
|
|
|
|
|
Tor Danielsen wrote: if(waste[i]<waste) {
First of all, I'm guessing this is a typo and that second "waste" should be "maksDager":
if(waste[i]<maksDager) {
Secondly, you should not initialize maksDager to 0. You should initialize it to one of the values in the waste array (note: what would happen if all the values in the array are a value of 1 or greater?):
if(waste.length > 0) {
maksDager = waste[0];
}
You could reset and increment sum like this:
if(waste[i] == maksDager) {
sum++;
}
if(waste[i] < maksDager) {
maksDager = waste[i];
sum = 1;
}
It's been a while since I used Java, so I can't remember how to chain else if statements and I don't remember if you need double equal signs (==) to check for equality, but you get the idea.
Finally, I have no idea what "maksDager" stands for. Perhaps rename it to something like "lowest".
Martin Fowler wrote: Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
|
|
|
|
|
Thanks for the fast and great reply.
I was just fast translating from Norwegian to English and also changing some words. So it all was way out of context but your example helped me to nail it. the finished code looks like
public int finnMaksDager() {
int maksDager = 0;
int sum = 0;
for(int i=0; i<nedbør.length; i++) {
if(nedbør[i] == maksDager) {
sum++;
}
if(nedbør[i] > maksDager) {
maksDager = nedbør[i];
sum = 1;
}
}
return sum;
}
and with
int[] nedbør = {1,4,8,4,3,8,4,8,6,7,4};
it will filter out the highest number in this case 8, and then return the number 3 for that is how many 8's there is in that array.
Regards
-Tor
|
|
|
|
|
how can i play sound in jfram using java
|
|
|
|
|
Have you searched in google[^]?
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
|
|
|
|
|
Is there a way to list the CPU usage per process of all the processes that are currently running in the system. What I mean is CPU % usage as is shown in the Taskmanager.
I have tried a few API like sigar and JavaSysMon but am not able to get accurate values of the %'s.
|
|
|
|
|
I would guess that the only way to get reasonable data if the JavaSysMon() method does not do it, is to use the native process and thread functions[^], using C/C++. This would mean you will have to write JNI[^] or JNA[^] code to act as the interface between C++ and Java.
|
|
|
|
|
Steps.
1. Find or create a command line tool that does that.
2. Use java Runtime.exec() to run it and get the results.
|
|
|
|
|
These days you should probably prefer ProcessBuilder to Runtime for executing external processes. ProcessBuilder does everything Runtime.exec does and more, so it's probably worth getting into the habit of using it. After all it has been around since 1.5 which came in years ago.
|
|
|
|
|
hey anyone can give some idea about stegnography coding in java???
|
|
|
|
|
Google "java steganography". You will get over 700,000 results. Maybe some of them might be useful, who knows?
|
|
|
|
|
You've already received some help, but instead of reacting in a sensible fashion you just decided to delete the whole question including my answer.
No help for your here, Sorry!
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
Here is my Applet code. It does not draw to the applet screen! I have tested that it loops, but nothing appears! Can i have some help figuring out this?
package net.petterroea;
import java.applet.Applet;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
public class TheBox extends Applet implements Runnable{
Input input;
Screen screen;
boolean running;
Thread thisThread;
Image backBuffer;
public TheBox()
{
thisThread = new Thread(this);
input = new Input(this);
this.setPreferredSize(new Dimension(640, 480));
this.addKeyListener(input);
this.addFocusListener(input);
this.addMouseListener(input);
Media.loadImages();
screen = new MainMenuScreen();
}
@Override
public void start()
{
running = true;
thisThread.run();
}
@Override
public void stop()
{
running = false;
}
@Override
public void run()
{
Graphics realg = null;
Graphics g = null;
while(running)
{
synchronized(this)
{
System.out.println(this.getWidth() + " " + this.getHeight());
realg = this.getGraphics();
if(backBuffer == null)
{
backBuffer = createImage(this.getWidth(), this.getHeight());
}
else if(backBuffer.getWidth(null) != this.getWidth() || backBuffer.getHeight(null) != this.getHeight())
{
backBuffer = createImage(this.getWidth(), this.getHeight());
}
g = backBuffer.getGraphics();
screen.tick(g);
realg.drawImage(backBuffer, 0, 0, null);
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
modified on Saturday, August 20, 2011 10:47 AM
|
|
|
|
|
See here[^], you need a paint() method to do the painting. Applets have a different life-cycle than normal Java apps.
|
|
|
|
|
Still does not work
public void paint(Graphics g) {
System.out.println("asd");
g.drawRect(0, 0,
getWidth() - 1,
getHeight() - 1);
}
...
...
...
...
repaint();
|
|
|
|
|
Try this:
g.drawRect(0, 0, getSize().width - 1, getSize().height - 1);
|
|
|
|
|
|
How to pass hashmap between (signed) applets?
My problem is that one applet scans for some data on a client PC. Then I need to display some text and components on that webpage (where the applet is) after the scan is completed.
One way to do the task is to move the applet component to new coordinates (position) with CSS but if I do this the applet reloads and starts the scan again.
Another way is to pass the hashmap data to another applet and make it visible.
And the last way is to store the hashmap data to some place (like RAM or smth. else) and then read it on relaunch of the applet. (is it possible to do wiht signed applet?)
I'd be really grateful for any working suggestions.
Thanks.
|
|
|
|
|