[Novice Help]what's wrong of my prime number programme !!~?
import javax.swing.*;
public class prime1 {
public static void main (String args[])
String number;
int n;
number = JOptionPane.showInputDialog( "Enter" );
n = Integer.parseInt( number );
for ( int counter = 2 ; counter < n ; counter++ ){
if ( n % counter != 0 )
System.out.println(
" It is a prime number ");
else
System.out.println(
" It is not a prime number ");
System.exit(0);
Why n only mod 2,but not mod all number which is smaller then n?
when i input 9 ,it is wrong ~
i discover that when 9 is mod 2 ,it will not continue to mod 3,4,5,6,7,8
The else only applied to the lien directly after it as there were no brackets to collect the two statements in an else block.
This means that the program was going into the for loop, checking you if/else then always running System.exit(0) which stopped the program before the loop had finnished.
Your statement "it is prime" is also in the wrong place. This really should say "it is no divisible by " + counter
as there are still numbers to check.
Try this revised version and see if you can understand the difference:
import javax.swing.*;
public class prime1 {
public static void main (String args[]) {
String number;
int n;
number = JOptionPane.showInputDialog( "Enter" );
n = Integer.parseInt( number );
for ( int counter = 2 ; counter < n ; counter++ ){
if ( n % counter != 0 )
System.out.println("It is not divisible by " + counter);
else{
System.out.println("It is not a prime number");
System.exit(0);
System.out.println("It is prime");
Similar Messages
-
Help, what's wrong with my upload function
Hi,
I want to write a java Bean (FileUploadBean) to upload the image files. I use a very simple txt file to test my Bean code, I've already know the syntax of the entity body of httpServletRequest object, it's like below:
"-----------------------------7d327203032e
Content-Disposition: form-data; name="toefl_form"; filename="C:\transfer\Picasso_ljm\jakarta-tomcat-4.0.1\webapps\junmin\image\test.txt"
Content-Type: text/plain
hi, this is a test;
-----------------------------7d327203032e--
My original test.txt file is only a line without '\r', '\n'.
"hi, this is a test."
But after call my upload function, the saved file is:
hi, this is a test.
There are 4 more bytes than the original file. Below is my FileUploadBean file, does anyone can figure out what's wrong in my upload function? Does the readLine read the return carriage and new line charactor too? Thank you very much!
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletInputStream;
import java.util.Dictionary;
import java.util.Hashtable;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileUploadBean {
private String savePath, saveFilename, filepath, filename, contentType;
// private Dictionary fields;
public String getFilename() {
return filename;
public String getFilepath() {
return filepath;
public void setSavePath(String savePath) {
this.savePath = savePath;
public void setSaveFilename(String saveFilename) {
this.saveFilename = saveFilename;
public String getContentType() {
return contentType;
private void setFilename(String s) {
if (s==null)
return;
int pos = s.indexOf("filename=\"");
if (pos != -1) {
filepath = s.substring(pos+10, s.length()-1);
// Windows browsers include the full path on the client
// But Linux/Unix and Mac browsers only send the filename
// test if this is from a Windows browser
pos = filepath.lastIndexOf("\\");
if (pos != -1)
filename = filepath.substring(pos + 1);
else
filename = filepath;
private void setContentType(String s) {
if (s==null)
return;
int pos = s.indexOf(": ");
if (pos != -1)
contentType = s.substring(pos+2, s.length());
public void doUpload(HttpServletRequest request) throws IOException {
ServletInputStream in = request.getInputStream();
// read boundary
byte[] line = new byte[256];
int i = in.readLine(line, 0, 256);
if (i < 3)
return;
int boundaryLength = i - 2;
String boundary = new String(line, 0, boundaryLength); //-2 discards the newline character
String newLine = new String(line, 0, i);
if (newLine.startsWith("Content-Disposition: form-data; name=\""))
if (newLine.indexOf("filename=\"") != -1) {
setFilename(new String(line, 0, i-2));
if (filename==null)
return;
//this is the file content
i = in.readLine(line, 0, 256);
setContentType(new String(line, 0, i-2));
// blank line
i = in.readLine(line, 0, 256);
// read the first byte of the file
i = in.read();
FileOutputStream fo = new FileOutputStream((savePath==null? "" : savePath) + saveFilename);
while (i != -1) {
// if this byte is equal to the first byte of the boundary, then first mark this place, and
// go ahead to check if it encounter the ending boundary. If it belongs to the file, then reset
// the read position and reread.
if( (char)i == '\r') {
in.mark(256);
i = in.read();
char c1 = (char)i;
i = in.read();
char c2 = (char)i;
i = in.readLine(line, 0, 256);
// if it is the end of request body, then close the OutputStream. Since the first byte is
// read already, then the final boundary size if +3
if ( (c1 == '\n') && (c2 == '-') && (i==boundaryLength+3) // + 3 is eof
&& (new String(line, 0, i).startsWith(boundary.substring(1)))) {
i = in.read();
else {
// it is not the eof, then write this byte into the outputStream and reset the read position
fo.write(i);
in.reset();
i = in.read();
} // end if
// else if (char)i != '-', then write directly to the fileOutputStream
else {
fo.write(i);
i= in.read();
} // end while
// close the fileOutputStream
fo.close();
}// end functionHI,
I find a bug myself. I add a line "i = in.read(line, 0, 256);" in doUpload function in the following position:
String boundary = new String(line, 0, boundaryLength); //-2 discards the newline character
i = in.read(line, 0, 256);
String newLine = new String(line, 0, i);
But still, when I was trying to read a image file, it even didn't finish reading and quit already! Still has bugs, need help!
Junmin -
Help: What's wrong to get TimeMillis in this code?
Hi,
I want to get the TimeMillis from a Calender.
Everytime the date and time and correct, however,
the Date and TimeMillis are always wrong. Can
anybody tell me how to get the correct ones?
tz = TimeZone.getTimeZone("PST");
cal = Calendar.getInstance(tz);
cal.setTimeZone(tz);
// get date and time
nYear = cal.get(cal.YEAR);
nMonth = cal.get(cal.MONTH);
nDayofMonth = cal.get(cal.DAY_OF_MONTH);
nDayofWeek = cal.get(cal.DAY_OF_WEEK);
nHour = cal.get(cal.HOUR_OF_DAY);
nMin = cal.get(cal.MINUTE);
nSec = cal.get(cal.SECOND);
int miliSec = cal.get(cal.MILLISECOND);
// get TimeMillis
java.util.Date date = (java.util.Date)(cal.getTime());
long nTime = date.getTime();
Thanks very much,
FanHi,
I'm having a similar problem.I have compare 2 dates and get the number of days between them.
Myplan is convert both dates to milisecs ,calculate, and re-convert to get days (how do i round it off only yo integers, no decimals).Any idea how i could do this?-
import java.util.Date;
import java.text.SimpleDateFormat;
class DateStamp{
public static void Main(String args[]){
doDate1;
String D;
int D1,D2,D3;
Date dt=new Date();
SimpleDateFormat sdf=new SimpleDateFormat("dd-mm-yyyy");
/*When using method .setDate(x) ,is x an integer or String?can x=2/5/2002 or 2-5-2002?*/
public void doDate1{
dt.setDay(12);
dt.setMonth(12);
dt.setYear(102);
D=dt.getTime();
D.parseInt(D1);D=""
D=sdf.getTime();
D.parseInt(D2);
int D3=D2-D1;
int D3=D3/86400000;/*How do you convert milisec-to-days?*/
D=D3.toString().
System.out.println(D+"days have elapsed since then");
the compiler said this-
File Compiled...
--------------------------- Javac Output ---------------------------
DateStamp.java:7: Invalid expression statement.doDate1;^DateStamp.java:14: Instance variables can't be void: doDate1public void doDate1; ^2 errors
this problem is persistant, and i'm a java newbie ,Does anyone know what's wrong here?
Thanks!
Regards,
aesh83 -
IPod touch won't turn on charge or register on pc help what is wrong how do I fix?
My iPod touch won't turn on or charge or register on the pc, what is wrong and how do. Fix it?
Try:
- iOS: Not responding or does not turn on
- Also try DFU mode after try recovery mode
How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
- If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
- If still not successful that indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
Apple Retail Store - Genius Bar -
I need Help what is wrong with my code?
Hi, well I am doing a class and a driver for a sphere. I need to compute the volume and surface area of the sphere I have the formula but when I run the program I don't get a result for neither. I would like to know what am I doing wrong? Here is my code. Thanks.
This is my class
import java.text.DecimalFormat;
public class Sphere
//Variable Declarations.
private int diameter;
private double radius;
//Constructor: Accepts and initialize instance data.
public Sphere(int sp_diameter)
diameter = sp_diameter;
//Set methods: Diameter
public void setDiameter(int new_diameter)
diameter = new_diameter;
//Get methods: Diameter
public int getDiameter()
return diameter;
//Compute volume and surface area of the sphere
public double getVolume()
return 4 * Math.PI * radius * radius * radius / 3;
public double getArea()
return 4 * Math.PI * radius * radius;
//toString method will return one line description of the sphere
public String toString()
DecimalFormat fmt =new DecimalFormat("0.###");
String sphere = " " + fmt.format(diameter) +fmt.format(getVolume()) + fmt.format(getArea());
return sphere;
Here is the driver
public static void main(String[]args)
Sphere sphere1, sphere2, sphere3;
sphere1 = new Sphere(10);
sphere2 = new Sphere(12);
sphere3 = new Sphere(20);
System.out.println("The sphere diameter are: ");
System.out.println("\tFirst Sphere diameter is: " + sphere1);
System.out.println("\tSecond Sphere diameter is: " + sphere2);
System.out.println("\tThird Sphere diameter is: " + sphere3);
//Prints the Sphere Volume and Surface Area.
System.out.println("\nTheir Volume and Surface Area: ");
System.out.println("\tSphere1: " + " " + sphere1.getVolume() + " " + sphere1.getArea());
System.out.println("\tSphere2: " + " " + sphere2.getVolume() + " " + sphere2.getArea());
System.out.println("\tSphere3: " + " " + sphere3.getVolume() + " " + sphere3.getArea());
//Change the diameter of the sphere.
sphere1.setDiameter(11);
sphere2.setDiameter(15);
sphere3.setDiameter(25);
System.out.println("\nNew diameter is: ");
System.out.println("\tFirst Sphere diameter is: " + sphere1);
System.out.println("\tSecond Sphere diameter is: " + sphere2);
System.out.println("\tThird Sphere diameter is: " + sphere3);
//Prints the Sphere Volume and Surface Area.
System.out.println("\nTheir Volume and Surface Area: ");
System.out.println("\tSphere1: " + " " + sphere1.getVolume() + " " + sphere1.getArea());
System.out.println("\tSphere2: " + " " + sphere2.getVolume() + " " + sphere2.getArea());
System.out.println("\tSphere3: " + " " + sphere3.getVolume() + " " + sphere3.getArea());
//Using the toString Method.
System.out.println("\nFirst sphere: " + sphere1);
}Maybe try a different constructor for sphere...
public Sphere(int sp_diameter, int sp_radius)
diameter = sp_diameter;
}nd maybe even a setRadius(int newRadius) and
getRadius().
Hope that helpsYou should not do it this way. The reason.. The radius is 1/2 the diameter. if you have seperate methods, then the programmer can set the diameter to X and the radius to 10X. not good.
A better way for the c'tor would be:
//Constructor: Accepts and initialize instance data.
public Sphere(int sp_diameter) {
diameter = sp_diameter;
radius = (double) diameter/2.0; //<-- I added this
}something similar in the setDiameter.. -
Help - What is wrong with my code ?
I have a cfform that does a db search, using a field and a
search criteria selected by the user. Here is my code :
<tr>
<td align="center" colspan="2">
<font size="3" face="Arial, Helvetica, sans-serif"
color="003366">
<b>Pick Request
Number: </b></font>
<input type="text" name="prNumber">
<select name="search_type">
<option value="Contains">Contains</option>
<option value="Begins With">Begins With</option>
<option value="Ends With">Ends With</option>
<option value="Is">Is</option>
<option value="Is Not">Is Not</option>
<option value="Before">Before</option>
<option value="After">After</option>
</select>
</td>
</tr>
Here is the query that I am using :
<cfquery name="getPRNum" datasource="docuTrack">
SELECT prNumber, fileName
FROM dbo.psFileInventory
<cfif form.search_type is "Contains">
Where dbo.psFileInventory.prNumber like '%#form.prNumber#%'
</cfif>
<cfif form.search_type is "Begins With">
Where dbo.psFileInventory.prNumber like '#form.prNumber#%'
</cfif>
<cfif form.search_type is "Ends With">
Where dbo.psFileInventory.prNumber like '%#form.prNumber#'
</cfif>
<cfif form.search_type is "Is">
Where dbo.psFileInventory.prNumber = '#form.prNumber#'
</cfif>
<cfif form.search_type is "Is Not">
Where dbo.psFileInventory.prNumber <>
'#form.prNumber#'
</cfif>
<cfif form.search_type is "Before">
Where dbo.psFileInventory.prNumber <= '#form.prNumber#'
</cfif>
<cfif form.search_type is "After">
Where dbo.psFileInventory.prNumber >= '#form.prNumber#'
</cfif>
</cfquery>
It cannot find any records with any of the search criteria
except for the = sign. However, when I do each criteria
individually, it works. For example, lif I enter 'PR8' in the form,
then like '#form.prNumber#%' in the query will give me all part
numbers that begin with PR8...etc, so I am pretty sure each of the
search criteria work.
But when I run it combined, it cannot find anything except
for the 'is' (=) criteria.
Can somebody please tell me what I am doing wrong ? I just
cannot see it.
Thanksquote:
...but wouldn't the query be in the action page ?
I'm not quite sure what you are asking here. Are
you asking if you have to run the query again in the action page?
If that is the question, then the answer is no, because that is why
I have you assign the query results on your query page
to a session variable so that you can make it available to
use just like you would the results of a cfquery on your action
page. In other words, if you did something like this
<cfset session.getPRNum_qry = getPRNum> on your query
page, you can do something like this on your action page...
<cfif IsDefined("session.getPRNum_qry.prNumber")>
<cfoutput query = "session.getPRNum_qry">
#prNumber# #fileName#
</cfoutput>
</cfif>
... which would loop through your "query" and display your
prNumber and fileName values for all rows returned. What you do
with them is up to you.....
Phil -
My macbook isnt starting. even charging isnt helping. what's wrong ?
first i thought that the battery was drained so i put it to charge but it was not of any help either. the charging was not showing and no light was turning on. i put it to charge for about 1 hour but nothing showed up.
please help.
need to submit my project by next week.Since the external display works without issue, it's more likely to be a problem with the internal display or possibly its cables and connections and not a graphics chip problem.
The LVDS cable is what carries video data, so you want to have a good look at it, checking both for physical damage and to see that it is well seated. Do the same with the inverter cable.
You can probably find a replacement LVDS cable:
http://www.ifixit.com/MacBook-Parts/MacBook-Pro-15-Inch-Models-A1226-A1260-Displ ay-Data-Cable/IF185-133
It seems to be sold out at the moment, but it may be available from a different source or later on from ifixit. The cable is much less expensive than the display, and may be worth a try.
Good luck! -
Help - what is wrong with my iMac ?
Hello
I'd really appreciate some help and advice with by iMac !
I'm having a really strange issue and I've no idea whats casuing it.
After using it for a while whichever window is open starts to black out - you can shut the window down but it remains there - if you click you mouse onto the screen you can pull a square out and it reveals the desktop wall paper underneath !
You cant force quit the open screens, the only way to stop it is to restart.
I have posted some photos for you to see - I hope someone can help !
[url=http://www.flickr.com/photos/52989912@N02/8686257908/][img]http://farm9.staticflickr.com/8538/8686257908_fa4d265b87_c.jpg[/img][/url]
[url=http://www.flickr.com/photos/52989912@N02/8686257908/]
[url=http://www.flickr.com/photos/52989912@N02/8685138651/][img]http://farm9.staticflickr.com/8123/8685138651_3fee66c385_c.jpg[/img][/url]
[url=http://www.flickr.com/photos/52989912@N02/8685138651/]
thanksthanks for replying
unfortunatle I blew the dust out of the vents before running temperature monitor so I can only say what the temps are now !
Ambient 16c
CPU A heatsink 31c
Graphics processor chip 1 41c
Graphics processor heatsink 1 41c
Graphics Processor temp diode 45c
Power supply 54c
Just to state again I blew a heck of a lot of dust out (with a compressor) - really amazed at how much there was
I probably blew too hard though as some dust has gone behind the screen but luckily you cant see it when the screen is on..
thanks -
Query gives me invalid number.Plz help what is wrong in this
SELECT A909_STG_CDC.B09_K, A909_STG_CDC.B09_L, A909_STG_CDC.B09_COD_SPROD, A909_STG_CDC.B09_DAT_REG, A909_STG_CDC.B09_INIBAL, A909_STG_CDC.B09_INTRT, A909_STG_CDC.B09_AREA, A909_STG_CDC.B09_ORIG_OFFICER_NO, A909_STG_CDC.B09_COST_CJER, DA901_STG_CDC.E901_BANK_NO, C919_STG_CDC.B19_SURNAME, C919_STG_CDC.B19_NAME, C919_STG_CDC.B19_TXT_ADR, C919_STG_CDC.B19_DES_COMPRCTY, C919_STG_CDC.B19_NUM_TPH, C919_STG_CDC.B19_DAT_BIRTH, PROC_DATE_FILE.PROC_DATE, A924_STG_CDC.B24_COUNTRY_COD
FROM
A909_STG_CDC, DA901_STG_CDC, C919_STG_CDC, PROC_DATE_FILE, A924_STG_CDC
where
A909_STG_CDC.B09_DAT_REG between (PROC_DATE_FILE.PROC_DATE) and (PROC_DATE_FILE.PROC_DATE-7)
and A909_STG_CDC.B09_J = DA901_STG_CDC.E901_J
and A909_STG_CDC.B09_K = DA901_STG_CDC.E901_K
and A909_STG_CDC.B09_L = DA901_STG_CDC.E901_L876801 wrote:
SELECT A909_STG_CDC.B09_K, A909_STG_CDC.B09_L, A909_STG_CDC.B09_COD_SPROD, A909_STG_CDC.B09_DAT_REG, A909_STG_CDC.B09_INIBAL, A909_STG_CDC.B09_INTRT, A909_STG_CDC.B09_AREA, A909_STG_CDC.B09_ORIG_OFFICER_NO, A909_STG_CDC.B09_COST_CJER, DA901_STG_CDC.E901_BANK_NO, C919_STG_CDC.B19_SURNAME, C919_STG_CDC.B19_NAME, C919_STG_CDC.B19_TXT_ADR, C919_STG_CDC.B19_DES_COMPRCTY, C919_STG_CDC.B19_NUM_TPH, C919_STG_CDC.B19_DAT_BIRTH, PROC_DATE_FILE.PROC_DATE, A924_STG_CDC.B24_COUNTRY_COD
FROM
A909_STG_CDC, DA901_STG_CDC, C919_STG_CDC, PROC_DATE_FILE, A924_STG_CDC
where
A909_STG_CDC.B09_DAT_REG between (PROC_DATE_FILE.PROC_DATE) and (PROC_DATE_FILE.PROC_DATE-7)
and A909_STG_CDC.B09_J = DA901_STG_CDC.E901_J
and A909_STG_CDC.B09_K = DA901_STG_CDC.E901_K
and A909_STG_CDC.B09_L = DA901_STG_CDC.E901_LThink you could make it any more difficult to read? First, apply a little formatting for your own sanity, then preserve that formatting in your post by using the 'code' tags:
SELECT A909_STG_CDC.B09_K,
A909_STG_CDC.B09_L,
A909_STG_CDC.B09_COD_SPROD,
A909_STG_CDC.B09_DAT_REG,
A909_STG_CDC.B09_INIBAL,
A909_STG_CDC.B09_INTRT,
A909_STG_CDC.B09_AREA,
A909_STG_CDC.B09_ORIG_OFFICER_NO,
A909_STG_CDC.B09_COST_CJER,
DA901_STG_CDC.E901_BANK_NO,
C919_STG_CDC.B19_SURNAME,
C919_STG_CDC.B19_NAME,
C919_STG_CDC.B19_TXT_ADR,
C919_STG_CDC.B19_DES_COMPRCTY,
C919_STG_CDC.B19_NUM_TPH,
C919_STG_CDC.B19_DAT_BIRTH,
PROC_DATE_FILE.PROC_DATE,
A924_STG_CDC.B24_COUNTRY_COD
FROM
A909_STG_CDC,
DA901_STG_CDC,
C919_STG_CDC,
PROC_DATE_FILE,
A924_STG_CDC
where A909_STG_CDC.B09_DAT_REG between (PROC_DATE_FILE.PROC_DATE)
and (PROC_DATE_FILE.PROC_DATE-7)
and A909_STG_CDC.B09_J = DA901_STG_CDC.E901_J
and A909_STG_CDC.B09_K = DA901_STG_CDC.E901_K Others have mentioned possible causes. If you had shown us the actual, full, and complete error message you could get better help. -
Help: What's wrong with my installed Developer 6.0?
Hi, Everyone,
I have a Developer 6.0 for Win95/NT4.0 version free downloaded
from OTN. My development ENV is: ORACLE 8.0.5 in one NT4.0
machine, OAS4.0.7 in the second NT4.0 machine.
Oracle8.0.5&OAS4.0.7 are installed and configed successfully.
Then I installed my Develper6.0 in the second NT4.0 machine. I
want to config my Develper6.0 Web developing/deployment
environment to deploy my developed Form/Report/Graphics. But I
cann't find the "Start->Oracle Developer R6.0->Server Wizard"
menu as illustrated in the chapter "Configuring your Oracle
Developer Server environment" of Oracle Developer Online
Manuals.So I can not config my Developer6.0 Server for Web
environment automatically. Who can tell me why? Without the
Server Wizard, how can I config my Form/Report/Graphics Server
manually?
Thanks in advance.
Robby
nullI've managed to install the wizard. I've started Oracle
installer and pointed to nt.prd file on developer 6 CD. Almost
at the end you find the server configuration wizard. You can
install him seperately.
For the whole story i've replied the thread
'URGENT HELP NEEDED: Configure the Developer 6.0 Web Server u'
Succes,
Werner
Brad (guest) wrote:
: Robby Shong (guest) wrote:
: : Hi, Everyone,
: : I have a Developer 6.0 for Win95/NT4.0 version free
downloaded
: : from OTN. My development ENV is: ORACLE 8.0.5 in one NT4.0
: : machine, OAS4.0.7 in the second NT4.0 machine.
: : Oracle8.0.5&OAS4.0.7 are installed and configed
successfully.
: : Then I installed my Develper6.0 in the second NT4.0 machine.
I
: : want to config my Develper6.0 Web developing/deployment
: : environment to deploy my developed Form/Report/Graphics. But
I
: : cann't find the "Start->Oracle Developer R6.0->Server
Wizard"
: : menu as illustrated in the chapter "Configuring your Oracle
: : Developer Server environment" of Oracle Developer Online
: : Manuals.So I can not config my Developer6.0 Server for Web
: : environment automatically. Who can tell me why? Without the
: : Server Wizard, how can I config my Form/Report/Graphics
Server
: : manually?
: : Thanks in advance.
: : Robby
: Server Wizard is not currently available you get to do the
setup
: manually for now. The installation documentation will guide
you
: through.
: Hope that helps
null -
Help: what's wrong with my code?
Hi. I'm using JNDI to connect to an SQL Server Database.
My machine can only handle jcreator or netbeans 4.1
is it possible for me to deploy or create such connection?
Please help me.
All suggestions would be very much appreciated.
import javax.sql.*;
import java.sql.*;
import java.io.*;
import javax.naming.*;
import java.util.*;
public class Test {
public static void main(String[] args) {
System.out.println("Starting test.");
setJVMProperties();
bindDataSource();
testDataSource();
System.out.println("Test finished.");
public static void setJVMProperties() {
Properties p = new Properties(System.getProperties());
p.setProperty("java.naming.factory.initial",
"com.sun.jndi.fscontext.RefFSContextFactory");
p.setProperty("java.naming.provider.url", "com.ibm.websphere.naming.WsnInitialContextFactory");
System.setProperties(p);
public static void bindDataSource() {
Context ctx = null;
try {
// On the 3 lines below, I get the error: package com.microsoft.jdbc.sqlserver does not exist
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
com.microsoft.jdbc.sqlserver.SQLServerDriver sqlServerDS = new
com.microsoft.jdbc.sqlserver.SQLServerDriver();
sqlServerDS.setServerName("PSERVER\\PINST");
sqlServerDS.setPortNumber("9080");
sqlServerDS.setDatabaseName("Customer");
sqlServerDS.setUser("neil");
sqlServerDS.setPassword("123");
ctx = new InitialContext();
ctx.rebind("jdbc/Name", sqlServerDS);
} catch (Exception e) {
System.err.println("Error binding datasource with jndi. " +e);
public static void testDataSource() {
try {
int id;
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("jdbc/Name");
Connection con = ds.getConnection();
CallableStatement cs = con.prepareCall("{? = Call Login(?,?)}");
cs.registerOutParameter(1, Types.INTEGER);
cs.setString(2, "123");
cs.setString(3, "123");
cs.execute();
id = cs.getInt(1);
System.out.println(id);
try {
cs.close();
con.close();
} catch (Exception e) {System.err.println(e);}
} catch (Exception e) {
System.err.println("Problem running db stuff." +e);
}hi. thanks so much for your tip. i followed it and finally my
com.microsoft.jdbc.sqlserver.SQLServerDriver sqlServerDS = new
com.microsoft.jdbc.sqlserver.SQLServerDriver();line is now recognized...
However, i get errors on the next 5 lines
sqlServerDS.setServerName("PSERVER\\PINST");
sqlServerDS.setPortNumber("9080");
sqlServerDS.setDatabaseName("Customer");
sqlServerDS.setUser("neil");
sqlServerDS.setPassword("123");the errors i get are something like: cannot find symbol
symbol : method setUser(java.lang.String)
location: class com.microsoft.jdbc.sqlserver.SQLServerDriver
sqlServerDS.setUser("neil");
as you might have noticed, i'm really new to java programming and i would very much appreciate all the help i can get. -
What's wrong with my Macbook Air?
Yesterday I was using it and everything seemed to be working perfectly. I turned it off and when I tried turning it back on, it got stuck on the grey screen with the apple at the beginning and didn't do anything else. I tried pressing shift while I turned it on and it finally worked. Now, it's being really weird, it's showing me a message saying 'Shockwave Flash has crashed' when I try loading a site on the internet, also, my Volume buttons are not working, they seem to be locked and if I turn it off and back on again, it takes forever to load.
Help what's wrong with it?Try booting to your Recovery Partion, by holding down the OPTION key while booting, and then select the Recovery Partion. Run Disk Utility from there, and Repair your Permissions, then Verify Disk. If Verify Disk finds reason to do so, run Repair Disk.
Shutdown, and see if it boots normally. If not, boot using the SHIFT key again (Safe Mode). From Safe Mode, update your Flash drom Adobe's site. Retry a normal boot. -
My data in ASCii format like +5.00824E-04,+6.06995E-04,+7.27587E-04. All becomes zero after Extract Numbers.vi in Labview 7. Please help what is wrong?
Extract Numbers.vi simply demostrate extracting decimal numbers. It is not used to extract exponential numbers. To do this, you need use the "Fract/Exp string to number.vi" from String >> String/Number conversion. Or the Scan From String.vi
-Joe -
Prime Number Formula in PL/SQL
Hi Friends,
Oracle 11.2.0.1
Windows XP Prof.
Two questions, but almost same nature :
1.Is there any formula by which we can get the total count of prime numbers for a given number; i mean suppose I says 10, it means it should return 3; i.e. there are total 3 prime number between 1-10.
Here I can use a function which will say me that a given number is prime or not, and i will loop up to that given number. But, this is not actually a Formula, its kind of calculation. I am just looking a fixed matehematical formula for it; if it exists or not. If exists, then how that PL/SQL block will looks like.
2.Suppose I wish to get 50 prime numbers (starting from 1), then what will be the 50th prime number, i mean upto which highest number my calculation will expanded.
If possible, this should also be based upon a fixed formula.
Not actually a business requirement, but my nephew (student of class 9th) asked me these questions. I said him, neither I am student of maths nor that much knowledgeable in PL/SQL.
I asked him, why you are looking these formulas. He said, just these questions raised in my mind and curious to know that is there a fixed formula in maths exists or not. I said him, "Have you asked from your Maths teacher?" He said "Yes, sir told me, that there is no such a fixed mathematical formula, because there is no fixed gap in their ranges, what you says?"
I thought, let me write here.
Regards
Girish SharmaUsing SQL & MODEL. Not the fastest solution, but calculates first 1000 prime numbers in 5 seconds:
VARIABLE cnt NUMBER
EXEC :cnt := 1000;
SELECT prime
FROM dual
CONNECT BY LEVEL < 3
MODEL
DIMENSION BY(
level i
MEASURES(
level prime,
0 probe,
0 is_prime,
2 prime_cnt
RULES ITERATE(1e9) UNTIL(prime_cnt[1] >= :cnt)
probe[any] = 2 * iteration_number + 3,
is_prime[1] = case
when min(mod(probe,prime))[i between 2 and probe[1] / 2] = 0
then 0
else 1
end,
prime_cnt[1] = prime_cnt[1] + is_prime[1],
probe[1] = case
when is_prime[1] = 0
then 1
else probe[1]
end,
prime[probe[1]] = probe[1]
PRIME
1
2
3
5
7
11
13
17
19
23
29
PRIME
31
37
41
43
47
53
59
61
67
71
73
PRIME
79
83
89
97
101
103
107
109
113
127
131
PRIME
137
139
149
151
157
163
167
173
179
181
191
PRIME
193
197
199
211
223
227
229
233
239
241
251
PRIME
257
263
269
271
277
281
283
293
307
311
313
PRIME
317
331
337
347
349
353
359
367
373
379
383
PRIME
389
397
401
409
419
421
431
433
439
443
449
PRIME
457
461
463
467
479
487
491
499
503
509
521
PRIME
523
541
547
557
563
569
571
577
587
593
599
PRIME
601
607
613
617
619
631
641
643
647
653
659
PRIME
661
673
677
683
691
701
709
719
727
733
739
PRIME
743
751
757
761
769
773
787
797
809
811
821
PRIME
823
827
829
839
853
857
859
863
877
881
883
PRIME
887
907
911
919
929
937
941
947
953
967
971
PRIME
977
983
991
997
1009
1013
1019
1021
1031
1033
1039
PRIME
1049
1051
1061
1063
1069
1087
1091
1093
1097
1103
1109
PRIME
1117
1123
1129
1151
1153
1163
1171
1181
1187
1193
1201
PRIME
1213
1217
1223
1229
1231
1237
1249
1259
1277
1279
1283
PRIME
1289
1291
1297
1301
1303
1307
1319
1321
1327
1361
1367
PRIME
1373
1381
1399
1409
1423
1427
1429
1433
1439
1447
1451
PRIME
1453
1459
1471
1481
1483
1487
1489
1493
1499
1511
1523
PRIME
1531
1543
1549
1553
1559
1567
1571
1579
1583
1597
1601
PRIME
1607
1609
1613
1619
1621
1627
1637
1657
1663
1667
1669
PRIME
1693
1697
1699
1709
1721
1723
1733
1741
1747
1753
1759
PRIME
1777
1783
1787
1789
1801
1811
1823
1831
1847
1861
1867
PRIME
1871
1873
1877
1879
1889
1901
1907
1913
1931
1933
1949
PRIME
1951
1973
1979
1987
1993
1997
1999
2003
2011
2017
2027
PRIME
2029
2039
2053
2063
2069
2081
2083
2087
2089
2099
2111
PRIME
2113
2129
2131
2137
2141
2143
2153
2161
2179
2203
2207
PRIME
2213
2221
2237
2239
2243
2251
2267
2269
2273
2281
2287
PRIME
2293
2297
2309
2311
2333
2339
2341
2347
2351
2357
2371
PRIME
2377
2381
2383
2389
2393
2399
2411
2417
2423
2437
2441
PRIME
2447
2459
2467
2473
2477
2503
2521
2531
2539
2543
2549
PRIME
2551
2557
2579
2591
2593
2609
2617
2621
2633
2647
2657
PRIME
2659
2663
2671
2677
2683
2687
2689
2693
2699
2707
2711
PRIME
2713
2719
2729
2731
2741
2749
2753
2767
2777
2789
2791
PRIME
2797
2801
2803
2819
2833
2837
2843
2851
2857
2861
2879
PRIME
2887
2897
2903
2909
2917
2927
2939
2953
2957
2963
2969
PRIME
2971
2999
3001
3011
3019
3023
3037
3041
3049
3061
3067
PRIME
3079
3083
3089
3109
3119
3121
3137
3163
3167
3169
3181
PRIME
3187
3191
3203
3209
3217
3221
3229
3251
3253
3257
3259
PRIME
3271
3299
3301
3307
3313
3319
3323
3329
3331
3343
3347
PRIME
3359
3361
3371
3373
3389
3391
3407
3413
3433
3449
3457
PRIME
3461
3463
3467
3469
3491
3499
3511
3517
3527
3529
3533
PRIME
3539
3541
3547
3557
3559
3571
3581
3583
3593
3607
3613
PRIME
3617
3623
3631
3637
3643
3659
3671
3673
3677
3691
3697
PRIME
3701
3709
3719
3727
3733
3739
3761
3767
3769
3779
3793
PRIME
3797
3803
3821
3823
3833
3847
3851
3853
3863
3877
3881
PRIME
3889
3907
3911
3917
3919
3923
3929
3931
3943
3947
3967
PRIME
3989
4001
4003
4007
4013
4019
4021
4027
4049
4051
4057
PRIME
4073
4079
4091
4093
4099
4111
4127
4129
4133
4139
4153
PRIME
4157
4159
4177
4201
4211
4217
4219
4229
4231
4241
4243
PRIME
4253
4259
4261
4271
4273
4283
4289
4297
4327
4337
4339
PRIME
4349
4357
4363
4373
4391
4397
4409
4421
4423
4441
4447
PRIME
4451
4457
4463
4481
4483
4493
4507
4513
4517
4519
4523
PRIME
4547
4549
4561
4567
4583
4591
4597
4603
4621
4637
4639
PRIME
4643
4649
4651
4657
4663
4673
4679
4691
4703
4721
4723
PRIME
4729
4733
4751
4759
4783
4787
4789
4793
4799
4801
4813
PRIME
4817
4831
4861
4871
4877
4889
4903
4909
4919
4931
4933
PRIME
4937
4943
4951
4957
4967
4969
4973
4987
4993
4999
5003
PRIME
5009
5011
5021
5023
5039
5051
5059
5077
5081
5087
5099
PRIME
5101
5107
5113
5119
5147
5153
5167
5171
5179
5189
5197
PRIME
5209
5227
5231
5233
5237
5261
5273
5279
5281
5297
5303
PRIME
5309
5323
5333
5347
5351
5381
5387
5393
5399
5407
5413
PRIME
5417
5419
5431
5437
5441
5443
5449
5471
5477
5479
5483
PRIME
5501
5503
5507
5519
5521
5527
5531
5557
5563
5569
5573
PRIME
5581
5591
5623
5639
5641
5647
5651
5653
5657
5659
5669
PRIME
5683
5689
5693
5701
5711
5717
5737
5741
5743
5749
5779
PRIME
5783
5791
5801
5807
5813
5821
5827
5839
5843
5849
5851
PRIME
5857
5861
5867
5869
5879
5881
5897
5903
5923
5927
5939
PRIME
5953
5981
5987
6007
6011
6029
6037
6043
6047
6053
6067
PRIME
6073
6079
6089
6091
6101
6113
6121
6131
6133
6143
6151
PRIME
6163
6173
6197
6199
6203
6211
6217
6221
6229
6247
6257
PRIME
6263
6269
6271
6277
6287
6299
6301
6311
6317
6323
6329
PRIME
6337
6343
6353
6359
6361
6367
6373
6379
6389
6397
6421
PRIME
6427
6449
6451
6469
6473
6481
6491
6521
6529
6547
6551
PRIME
6553
6563
6569
6571
6577
6581
6599
6607
6619
6637
6653
PRIME
6659
6661
6673
6679
6689
6691
6701
6703
6709
6719
6733
PRIME
6737
6761
6763
6779
6781
6791
6793
6803
6823
6827
6829
PRIME
6833
6841
6857
6863
6869
6871
6883
6899
6907
6911
6917
PRIME
6947
6949
6959
6961
6967
6971
6977
6983
6991
6997
7001
PRIME
7013
7019
7027
7039
7043
7057
7069
7079
7103
7109
7121
PRIME
7127
7129
7151
7159
7177
7187
7193
7207
7211
7213
7219
PRIME
7229
7237
7243
7247
7253
7283
7297
7307
7309
7321
7331
PRIME
7333
7349
7351
7369
7393
7411
7417
7433
7451
7457
7459
PRIME
7477
7481
7487
7489
7499
7507
7517
7523
7529
7537
7541
PRIME
7547
7549
7559
7561
7573
7577
7583
7589
7591
7603
7607
PRIME
7621
7639
7643
7649
7669
7673
7681
7687
7691
7699
7703
PRIME
7717
7723
7727
7741
7753
7757
7759
7789
7793
7817
7823
PRIME
7829
7841
7853
7867
7873
7877
7879
7883
7901
7907
1000 rows selected.
Elapsed: 00:00:05.07
SQL>
SY. -
Installed the update tonight and now my phone (Lumia 928) won't power up. I've tried a soft reset, but the screen goes from the Nokia logo to a red Verizon screen to a black screen. Tried it 10 times with the same result. What's wrong and how do I fix it? Help!
Oh no Mr.Ected!
I can see if we can get your phone back on! I understand how important it is to have a phone. Have you tried this to see if we can get it back on? http://vz.to/1DZhteH . If it is still goes to a red Verizon screen and then to black we might need to do a master reset. While the phone is off try this:http://vz.to/1DZhXkU Be mindful this is the last resort because it will erase everything on the phone. If you have done back up assistant in the past you will be able to get you contacts back. Please let me know if you need any more help.
AmberF_VZW
Follow us on Twitter @VZWSupport
Maybe you are looking for
-
Hi Apple Support Communities, I need some support. After loading Mavericks with lots of happiness primarily to be able to use dictation, see my previous query. Since then I have also had this come up on my Macbook Air everytime I start it. To open "C
-
Can I delete an account without loosing all the emails?
I now haw 2 accounts in MacMail, each with their own handfull of mail. One account is for a now obsolete email address. I'd like to delete it, leaving me with only the current and active email account / address. However, I can't loose all of the emai
-
Bad sound after installing Leopard
After my Leopard install the iTunes sound is horrible. It sounds like AM radio ... When I play the same song over Frontrow it sounds fine.... What could be wrong? Ch
-
Creating GRN by the use of BAPI
Dear All, I want to create, GRN by the use of BAPI. For this i am using BAPI BAPI_GOODSMVT_CREATE I have passed all the required field in this BAPI. System without any error generating GRN Number, When i am looking this GRN NUmber in MB03 Transactio
-
Authentication Configuration Files
I have a situation with my EDGE installation where I cannot log in (to anything, even the CMC) because one of my authentication parameters is incorrect. The error message I get is: The NT Authentication plugin failed to verify the domain "seakr". Pl